This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes destroy() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "destroy() method" Watch "destroy() method" New topic

destroy() method

Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422

1. Because destroy() is callback method which is called by Container when the server is about to shutdown, Do we need to override it (or) leave it to the container.
2. Even though I write couple of System.out.println() statements in destroy() method and shutdown the server, they are not printed on the console.

Please advice.

OCPJP 6.0-81% | Preparing for OCWCD | |
Javin Paul
Ranch Hand

Joined: Oct 15, 2010
Posts: 281

Hi Hari,

As per my knowledge destroy() method is called before a Servlet gets unloaded from Container. though its upto container implementation on which other cases its provides callback to destroy() method.

Javin - java classpath - Java67 - java hashmap - java logging tips java interview questions Java Enum Tutorial
I agree. Here's the link:
subject: destroy() method
Similar Threads
destroying the servlet
Servlet Lifecycle
When Servlet's delete() method is called?
destroy() doubt
Can i use finalize method instead of destroy in servlets