"Richard A. Sand" wrote:

>  Hi all, I'm having problems cleaning up session beans.  I have beans
> that access databases that I use in multiple JSP pages, and have
> session scope.  How can I figure out when to close those beans?  When
> a bean is destroyed I need to close its result set.  Right now, as I
> navigate my site, I watch Jrun's JVM grow from about 10 megs of memory
> to around 50, and it keeps going unless I restart the JVM.  Is there
> some event that I can catch when a user's session ends so I can clean
> up those beans properly? Thanks!
> Richard Sand ([EMAIL PROTECTED])
> http://www.vgalleries.com

Have your bean implement the HttpSessionBindingListener interface.  That
way, the bean's valueBound() method will be called when the bean is
added to the user's session, and valueUnbound() will be called when the
bean is removed.  One nice feature is that this happens for you
automatically when the session is invalidated or times out as well.

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to