logo       

Get a list of all sessions of an application: msg#00050

java.enhydra.general

Subject: Get a list of all sessions of an application

Hello!

we use Enhydra 5 for a intranet project. I want to display a page with all
currently connected users (=sessions) and tried the code below.
The problem ist that in the method activeSessions() I get all sessionskeys but
sm.getSession(key) returns only the calling session and null for every other.
When I register my thread using Enhydra.register(), the result is the same.

So any solution?

------------------------------------------------
private Vector activeSessions() {
Vector sessions = new Vector();
try{
StandardSessionManager sm = (StandardSessionManager)
Enhydra.getSessionManager();
Enumeration keys = sm.getSessionKeys();
while(keys.hasMoreElements()) {
sessions.addElement(sm.getSession((String) keys.nextElement()));
}
} catch (Exception ex) {
// log it
}
return sessions;
}

To get the session listing
Enhydra.register(Thread.currentThread(), getComms().application);
try{
sessions = activeSessions();
} finally {
Enhydra.unRegister(Thread.currentThread());
}


--
Dipl. Inform. Boris Klug, control IT GmbH, Germany


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise