tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: How to keep track of sessions
Date Wed, 14 Aug 2002 12:58:44 GMT
So my first question is, why?  If you could describe the motivation /
requirements / goals for your need to keep track of all the sessions,
perhaps someone could suggest an alternative approach.

>If tomcat is restarted then the sessions are persisted fine. However my
>vector of sessions is lost so I have no record of sessions that were
>during a previous tomcat run.
>Any idea how I could find or keep the list of previously created

Sessions are not meant to be persisted across server restarts.  

Perhaps you are only interested in specific attributes of the sessions?
In that case, the Singleton pattern comes to mind to be used as follows:

- Have an object, MySessionInfoHolder, that holds the stuff you need
about the session, for example some attributes.  You probably do *not*
want to keep the session ID.

- Have a singleton, MySessionInfoManager, that keeps a set (no
duplicates) of these MySessionInfoManager objects.

- Your session listener (either a Session or a SessionAttribute
listener, or both) would extract the proper info from a Jakarta session
object and store it in the manager.

- On context shutdown, persist the stuff in MySessionInfoManager using
castor (or any of the other similar packages) or your own serialization
/ XML / JDBC / whatever mechanism.

- On context startup, recall the stuff from XML / the database /
wherever into the manager.

Would that approach work for your needs?

Yoav Shapira
Millennium ChemInformatics

View raw message