wood burning stoves 2.0
The moose likes Servlets and the fly likes destroy() method of servlet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "destroy() method of servlet. " Watch "destroy() method of servlet. " New topic

destroy() method of servlet.

Varun Monga

Joined: Dec 15, 2006
Posts: 2
What if I call the destroy() method of servlet in the init() method of servlet ?

SCJP <br />Software Engineer<br /> <br />< href="http://varunmonga.blogspot.com>My Blog</a>
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Welcome to JavaRanch.

The question is moot, because servlet code never calls the destroy method (or the init method). The servlet container does that.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1323

for more see this article about Servlet Container Works.. by Budi Kurniawan

[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

The code would run, but the Servlet wouldn't actually be taken out of service. The destroy method is a method like any other method, but its purpose has to do with the lifecycle of the Servlet, which is managed by the web container.

A developer should never call the init or destroy method of a Servlet. We just put pertinent code there, and allow the container to invoke it.

-Cameron McKenzie
I agree. Here's the link: http://aspose.com/file-tools
subject: destroy() method of servlet.
jQuery in Action, 3rd edition