I had to do something like this and I did use the HttpSessionListener
interface (requires 2.3 servlet API support in your container) as part of
the solution. However, it alone is not sufficient. The callbacks for the
session creation and destruction events happen so early and so late
respectively that you do not have access to any session data other than the
sessionID. The solution I came up with was to record logins within the
webapp to a tracking table *and* store the sessionID as a field in these
records. Then, you can use the sessionDestroyed() callback to check to see
if there is a login record that is still active that needs to be flagged as
terminated. You have to go through all these hoops because you can't rely on
the user explicitly logging out. So, to update the tracking table to
reliably indicate who is currently logged in you have to do this. You will
hit the sessionDestroyed() callback whether they explicitly log out and you
expire the session, or the session simply times out on its own because of
inactivity (or as a result of closing the client-side browser window without
explicitly logging out).

Hope this helps, Van

Mike "Van" Riper
Silicon Valley Struts User Group
http://www.baychi.org/bof/struts/
mailto:[EMAIL PROTECTED]

> -----Original Message-----
> From: Nick Heudecker [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 15, 2004 1:43 PM
> To: Struts Users Mailing List
> Subject: Re: Enumerating sessions
> 
> 
> Wouldn't this do it?
> 
> http://jakarta.apache.org/tomcat/tomcat-5.0-doc/servletapi/jav
> ax/servlet/http/HttpSessionListener.html
> 
> Frank Zammetti wrote:
> 
> > Hello all... is there any good way to enumerate all 
> sessions under a 
> > given webapp?  I know there used to be the SessionContext, 
> but that has 
> > since been deprecated as of servlet spec 2.1 I believe... Is there 
> > anything in Struts that might help?
> > 
> > Basically I'm just looking for an accurate way to display 
> all currently 
> > logged on users, and also have the ability to add a session 
> attribute to 
> > all of them (think broadcast messages and forced graceful 
> logoffs).  I 
> > keep hearing the term "Session Listenter", but my research 
> is turning up 
> > server-specific (or third party-specific references), and I 
> need this to 
> > be server-nuetral.
> > 
> > I could I guess create a wrapper class that is called to 
> create or kill 
> > a session, as well as to add of remove attributes, but I'd prefer 
> > something that won't require me to change a lot of code, or 
> any really!
> > 
> > Thanks in advance for any ideas!
> > 
> > Frank
> > 
> > _________________________________________________________________
> > MSN 9 Dial-up Internet Access fights spam and pop-ups – now 
> 3 months 
> > FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> 
> 
> -- 
> Nick Heudecker
> System Mobile, Inc.
> Email: [EMAIL PROTECTED]
> Web: http://www.systemmobile.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to