tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: How to know the list of the active sessions
Date Wed, 06 Oct 2004 13:37:47 GMT


>Enumeration list = servletContext.getActiveSession();
>To solve this problem i have put a list attribute in the context. And
>use a session listener to refresh this list ... but the problem is that
>the session are persistent during a stop but not the context attributes
>which became outdated ...

Your solution isn't far from what you need.  But you might want to read
the Servlet Spec or its JavaDocs a tiny bit more, where you'll discover
the HttpSessionActivationListener.

Write a listener that's both an HttpSessionListener and an
HttpSessionActivationListener.  Have this listener maintain a list (or
map by session ID, or Set to prevent duplicates, or whatever data
structure fits your needs) of active sessions.  Add to the list both
when a session is created and when it's activated, and remove from it
both when it's destroyed and when it's passivated.  At least that will
be the initial version of your listener.  Test and tweak as needed for
whatever your requirements are.


This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message