aspose file tools*
The moose likes Servlets and the fly likes destroy() for Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "destroy() for Servlet" Watch "destroy() for Servlet" New topic
Author

destroy() for Servlet

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
Is it guaranteed that this will be called when the server shuts down? If not, is there something that ensures a servlet is called on shutdown?
I am logging in every servlet (in the destroy() method) whether it was called. The weird thing is ONLY the servlets that are loaded on startup had their destroy() method called. Why is this?
[ January 29, 2003: Message edited by: Robert Paris ]
Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
I figured out why some weren't being called. They'd never been accessed, so they weren't instantiated, hence they couldn't be destroyed. (Duh - *smack my head*)
However, I still want to know if this is required: that the server calls all servlet "destroy()" methods on shutdown.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
It is in the servlet API as required but who knows if all servlet containers implement it correctly.
Bill
vijith vayanippetta
Greenhorn

Joined: Nov 07, 2001
Posts: 3
Whatever servlets are loaded by the server, (ie init method of the servlet is invoked), will be destroyed by the server at shutdown.Only if the server crashes the destroy method will not be invoked.
Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
I've had issues with this myself. Using Tomcat 4.1.18 it would not execute the destroy() method after using my servlet.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
I've had issues with this myself. Using Tomcat 4.1.18 it would not execute the destroy() method after using my servlet.

How were you shutting Tomcat down?
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: destroy() for Servlet
 
Similar Threads
How to destroy servlet before weblogic shuts down...
destroy method
when is destroy called
how many times init() method gets called
When a Servlet destroy method is called.