actually, whether or not this works (well enough) will depend on the Servlet/JSP
engine that you're running on. I know that WebLogic doesn't automatically clean up
sessions right as they're invalidated, and the session doesn't start removing
attributes (causing the call to your valueUnbound method) until the servlet engine
decides to physically remove the session object from memory. You might need to
investigate further to see how your platform influences this approach.
good luck,
Rob
Rob van Oostrum wrote:
> 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
===========================================================================
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