Thanks - that helps.

-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 25, 2001 11:32 AM
To: '[EMAIL PROTECTED]'
Subject: Re: HttpSessionListener




On Mon, 25 Jun 2001, Gogineni, Pratima wrote:

> Hi,
> 
> This question is more to do with servlets & not directly related to struts
> (other than that I am using struts) to develop this application.
> 
> I was trying to find a way to detect when a session was destroyed either
> because the user logged out or because of a session time out or something
> else. 
> 
> I looked at the API and found that 2.3 has lifecycle events, one of them a
> HttpSessionListener. I am working with 2.2 I was wondering if there is an
> alternative to this in 2.2 & how people handled this when these events
didnt
> exist. 
> 
> Does one have to write a thread that continuously monitors if a session
> still exists?
> 
> Thanks
> Pratima
> 

In servlet 2.2, the most common approach to this problem involves the use
of the HttpSessionBindingListener interface.

Basically, you need to arrange that, as part of your user logon
processing, you create a session attribute that implements this
interface.  The valueBound() method will be called at this time.

Now, when the session is invalidated or times out, one of the things that
happens is that all session attributes are removed.  Thus, the
valueUnbound() method of your bean will be called, so that you can do
whatever processing is required.

Craig

Reply via email to