Here's a different way. Implement HttpSessionListener (and put it in web.xml)
and do this:

  public void sessionCreated(HttpSessionEvent event)
  {
    Set<HttpSession> allHttpSessions =
event.getSession().getServletContext().getAttribute("allSessions");
    if (allHttpSessions == null) {
      allHttpSessions = new HashSet<HttpSession>();
      event.getSession().getServletContext().setAttribute("allSessions",
allHttpSessions);
    }
    synchronized (allHttpSessions)
    {
      allHttpSessions.add(event.getSession());
    }
  }


Then in your code you can getServletContext().getAttribute("allSessions")
and count them.

Pretty sure the code above as it is is still not thread safe though, need to
synchronize on something else. 
-- 
View this message in context: 
http://tapestry-users.832.n2.nabble.com/count-active-users-tp5582131p5583556.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to