title: Xpages - Get number of active sessions (Lotus Domino 8.5.2)
body: <p>How do I get the number of active sessions in Xpage. I'm trying to use managed beans but it just returns a weird string. Here's the simple code: </p>
  
  <pre>
  import javax.servlet.http.HttpSessionEvent;
  import javax.servlet.http.HttpSessionListener;
  
  public class SessionCounterListener implements HttpSessionListener {
  
    private static int totalActiveSessions;
  
    public static int getTotalActiveSessions(){
      return totalActiveSessions;
    }
  
    public void sessionCreated(HttpSessionEvent arg0) {
      totalActiveSessions++;
      System.out.println("sessionCreated - add one session into counter");
    }
  
    public void sessionDestroyed(HttpSessionEvent arg0) {
      totalActiveSessions--;
      System.out.println("sessionDestroyed - deduct one session from counter");
    } 
  }
  </pre>
  
  <p>I got this from <a href="http://www.mkyong.com/servlet/a-simple-httpsessionlistener-example-active-sessions-counter" rel="nofollow">here</a>. But when I call <code>SessionCounterListener.getTotalActiveSessions()</code>, it only returns 0 (regardless if someone is logged in). </p>
  
  <p>If you have the time, you can check out my test database <a href="https://www.dropbox.com/s/zs098ne95t4cnl1/test_java.nsf" rel="nofollow">here</a>. </p>
  
  <p>Please help me. Thanks a lot!</p>