看看javax.servlet.http 
Interface HttpSessionBindingListener
其中的两个方法
void valueBound(HttpSessionBindingEvent event) 
          Notifies the object that it is being bound to a session and identifies the session. 
 void valueUnbound(HttpSessionBindingEvent event) 
          Notifies the object that it is being unbound from a session and identifies the session. 

解决方案 »

  1.   

    数据库中写不正确
    在application中建立用户对象,每隔一段时间,用户重置该对象,服务器气动一个线程定期检查该对象
      

  2.   

    运用session实现Interface HttpSessionBindingListener自己看一下api doc
      

  3.   

    用onunload事件,招待onunload时,弹出一个新窗口,
    window.open("sss.jsp","","top=2000,left=2000,"),在这个页上再用application.removeAttribute();然后人数减1.你试一下吧,我是这样做的!
      

  4.   

    to win886688() 
      具体一点嘛我一定给你分的
      

  5.   

    login.jsp<%@ page import="OnLine"/>
    <%
       OnLine ol = session.getAttribute("myonline");
       if (OnLine == null)
    {
       OnLine oo = new OnLine();
       session.setAttribute("myonline", oo);
    }
    %>
    OnLine.javaclass OnLine implements HttpSessionBindingListener
    {
    public OnLine()
    {}void valueBound(HttpSessionBindingEvent event) 
    //Notifies the object that it is being bound to a session and identifies the session. 
    {
        Integer counter = getServletContext().getAttribute("onlinecounter");
        int c = counter.intValue();
        getServletContext().setAttribute("onlinecounter",new Integer(c));
    }
     void valueUnbound(HttpSessionBindingEvent event) 
     //         Notifies the object that it is being unbound from a session and identifies the session
    {
      基本通上,减少计数器。
    }}
      

  6.   

    哦, 应该把构造函数改为:OnLine(ServletContext sc)jsp调用的时候把 application  船进去就行了!