How to get the number of active sessions in Xpage. I am trying to use managed beans, but it just returns a weird string. Here is a 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 it from here . But when I call SessionCounterListener.getTotalActiveSessions(), it returns 0 (regardless of whether someone is logged in).
If you have time, you can check my test database here .
Please help me. Many thanks!
Jairo source
share