logo       

Re: Get a list of all sessions of an application: msg#00051

java.enhydra.general

Subject: Re: Get a list of all sessions of an application

Boris,

See <comment> below. You should be aware that the call to sm.getSession()
includes an internal 'touch()', so the inactivity time will always be reset
when you use this. (I modified the Enhydra source to include a special
version of getSession() that did not include the call to 'touch()'.)

Regards,

Terry

----- Original Message -----
From: "Boris Klug" <boris.klug@xxxxxxxxxx>
To: <enhydra@xxxxxxxxxxx>
Sent: Friday, December 20, 2002 6:51 AM
Subject: Enhydra: 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()));




<comment>
Try changing the above line to this:

sessions.addElement(sm.getSession(Thread.currentThread(),(String)keys.nextEl
ement()));
</comment>




> }
> } 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
>
> _______________________________________________
> Enhydra mailing list
> Enhydra@xxxxxxxxxxx
> http://www.enhydra.org/mailman/listinfo.cgi/enhydra
>


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

News | FAQ | advertise