ServletContext lifecycle

J

Joe Attardi

Am I correct in the assumption that an instance of ServletContext
associated with one particular web application will remain "alive"
during the entire life of the application?

I previously had some setup/cleanup code in the init() and destroy()
methods of a servlet, but since the container is free to discard and
re-initialize a servlet instance, my cleanup code was being called
while the application was still running.

If I move this code to a ServletContextListener, will the
contextInitialized and contextDestroyed only be called once for the
lifetime of the application?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top