*
The moose likes Servlets and the fly likes When a Servlet destroy method is called. 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 "When a Servlet destroy method is called." Watch "When a Servlet destroy method is called." New topic
Author

When a Servlet destroy method is called.

sasikumar srinivasan
Greenhorn

Joined: Aug 27, 2009
Posts: 4
When a servlet destroy method is called, What is the timeout period after that the container calls the destroy method.
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452

a servlet is loaded when the request comes for it and stay loaded until the application is on the server.

when the application is about to be shut down the destroy method is called for cleanup etc.

avi sinha


SCJP 5.0 SCWCD 5.0
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
What is the timeout period after that the container calls the destroy method.


There is no "timeout" period. If a container decides to remove a servlet, for whatever reason, it will ensure there are no pending requests when destroy is called. Subsequent requests for that servlet will get an error message. Search for "servlet life cycle tutorial" to get expanded discussions.

Bill
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 597

William Brogden wrote:
Subsequent requests for that servlet will get an error message.


Why would this happen? I would assume that if the server removed a servlet for some reason (other that shutting down, of course) a subsequent call to that servlet should load it again (call its init() again).


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

Sam Mercs wrote:
William Brogden wrote:
Subsequent requests for that servlet will get an error message.

Why would this happen? I would assume that if the server removed a servlet for some reason (other that shutting down, of course) a subsequent call to that servlet should load it again (call its init() again).

Yes. If the servlet throws UnavailableException (with a specific time) until that time expires response will return SC_SERVICE_UNAVAILABLE (503). Also the container may remove the instance as William stated may be to conserve memory etc... Any subsequent requests should be sent to a newly initialized instance.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
Don't get me started about those stupid light bulbs.
 
subject: When a Servlet destroy method is called.
 
Similar Threads
Every time should i call destroy()
destroy() method effect
when is destroy called
destroy method
Destroy() method in the life cycle of the servlet