Tim Hagberg wrote: My first assumption was that these servlets were being destroyed after every use, and thus the init method was being called every time one of the respective actions was performed, however I can't find any evidence of destroy methods being called. Has anyone seen anything like this, and are there easy ways to find out if a servlet is being destroyed before the container is shut down?
Hi Tim,
We have init and destroy methods which serves the purpose but it is invoked whenever a servlet instance is created (Only once if it's the FIRST Request since at that time we won't be having any instance for THAT servlet ) and destroyed .NOT for every servlet Request.
For every request the SAME servlet instance is used with a NEW Thread.
As same with init, destroy method will also be called only if don't have any request for that particular Servlet INSTANCE
Following is the extract form API
==========================
Destroy
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. This method is only called once all threads within the servlet's service method have exited or after a timeout period has passed. After the servlet container calls this method, it will not call the service method again on this servlet.
This method gives the servlet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the servlet's current state in memory.
Hope this will clear your doubt.