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:
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"); } }
I got this from here. But when I call SessionCounterListener.getTotalActiveSessions()
, it only returns 0 (regardless if someone is logged in).
If you have the time, you can check out my test database here.
Please help me. Thanks a lot!