--- Woodchuck <[EMAIL PROTECTED]> wrote:
> hihi all,
> 
> which class/function do i need to extend/override so that i can
> absolutely guarantee that code is executed before the web app is
> killed?  ie. if someone stops Tomcat or stops my Struts web app
> instance, and i want to execute some code before it really goes
> down.
> 
> is this easy/possible?

Certainly, just create a class that implements the
javax.servlet.ServletContextListener interface, and configure your
webapp's web.xml file as follows:

<listener>
   <listener-class>your.new.ListenerClass</listener-class>
</listener>

Put the code you want to execute before the webapp is shut down in
the contextDestroyed() method of your listener class.

You can configure several types of event listeners, including
listeners that fire when a session is created or destroyed, an object
is bound or unbound in a session, or an attribute is changed.  Refer
to the Servlet 2.3 or 2.4 spec for further details.

Brian


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to