Xpages - Get number of active sessions
- by Jairo
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 | 0;
}
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 a weird string, example com.gs3.beans.SessionCounterListener@46c446c4. Please help me. Thanks a lot!