Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When a Servlet destroy method is called.

 
sasikumar srinivasan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a servlet destroy method is called, What is the timeout period after that the container calls the destroy method.
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Vijitha Kumara
Bartender
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic