Felip Miralles wrote:
>
> How would I specify some code to be executed when closing a session, for
>
> example, if I want to close a database connection that I opened when the
>
> session started?
> In other words, how can I write code in a way similar to how global.asa
> works in ASP? global.jsa seems only to be available in jrun, so there
> should be another way, am i wrong?

First of all, I suggest you look at using a connection pool instead of
keeping a connection allocated to each session; it's much more scalable
and avoids the problem you face now.

But if you really need to do some cleanup when a session is terminated,
you can let the objects you place in the session scope implement the
HttpSessionBindingListener interface (see the Servlet spec for details).
The objects will then be notified when the session terminates and can
do whatever they need.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
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