1) You write a class that implements
javax.servlet.http.HttpSessionBindingListener
2) You put your cleanup code (or the calls to your cleanup code) in the
valueUnbound method.
3) When your session is instantiated (i.e. when the user hits the first JSP),
you create a new instance of the class you created in step 1) and you register
it with the session using the HTTPSession.setAttribute() method. The name of
the attribute is trivial, assuming that your application does not need to
retrieve the object for any other purpose.
What this does, is that when the Session is about to be invalidated, it tries
to unbind all objects that have been bound to it. If it finds that a bound
object implements the HttpSessionBindingListener interface, it will call the
valueUnbound() method on that object.
Check the J2EE API docs for more info
enjoy,
Rob
Marino Vittorio wrote:
> Jsp gurus,
> I've a couple of quick questions:
>
> 1) How can I trap a session timeout. I need to do some cleanup before
> invalidating the session itself.
>
> 2) I've two frames in my app. When the session expires the user is
> redirected to the login page, but not full screen(browser) as I'd like to,
> but only in the right frame. Do I need to use Java Script?
>
> Thanks
>
> ==========================================================================
> =
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets