View Full Version : Clean up when shuting down tomcat
nusa
Sep 12th, 2007, 10:33 AM
Hi,
I have a web app that generates some temp files.
When I shutdown the tomcat, I would like to do some clean up ( delete those temp files ).
Anyone knows how can I do that ? Any sample code ?
Thanks.
Marten Deinum
Sep 12th, 2007, 10:39 AM
You could create a ServletContextListener and implement the ContextDestroyed method.
nusa
Sep 12th, 2007, 02:52 PM
Thanks for your reply. It looks like I can use ContextLoaderListener by setting it in my web.xml :
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>
But how can I invoke contextDestroyed() method ?
Thanks again.
Marten Deinum
Sep 12th, 2007, 03:07 PM
You need to implement your OWN ServletContextListener. The ContextLoaderListener is only for (un)loading the application context.
The methods defined by the ServletContextListener get called automatically by your servlet container. The contextDestroyed will be called when shutting down the application (server).
nusa
Sep 12th, 2007, 03:14 PM
You need to implement your OWN ServletContextListener. The ContextLoaderListener is only for (un)loading the application context.
Thanks mdeinum.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.