我已经实现登录,和聊天框架,我想获得所有在线的成员,并将其显示,当一个新用户登录或注销后,在线列表就会更新!
我想问是不是在ServletConText中创建一个UserList数组?每登录一个用户,就更新UserList, 可怎么实现这个数组的操作呢,是在登录成功后就,添加一个用户到这个UserList里?
求各位大哥们教我,

解决方案 »

  1.   

      J2EE中监听器Listener的应用http://blog.csdn.net/uciqxkj/archive/2008/11/06/3238853.aspx
      

  2.   

    如何给分和结贴?
    http://community.csdn.net/Help/HelpCenter.htm#结帖
      

  3.   

    我是在客户端的js定时向后台发送一次请求,如果后台内的application中的存放用户的list变化了,就返回数据让前台更新一下。
      

  4.   

    <!-- MyServlet--> public void doPost(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
      response.setContentType("text/html;charset=utf-8");
         request.setCharacterEncoding("utf-8");
         ServletContext application=this.getServletContext();
         String info=request.getParameter("talk");
         List list=(List)application.getAttribute("app");
         if(list==null) {
          list=new ArrayList();
         }
         list.add(info);
         application.setAttribute("app", list);
         request.getRequestDispatcher("index.jsp").forward(request, response);    
     }