Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Life Cycle  RSS feed

 
Prashant Matti
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that the init() method will be called only once when servlet is initialized, and service()method many times as per request.But i would like to know whether the destroy() method called after every service method() or only once when the object is removed out of the Container, ie. only once like init() method
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

This is really the wrong forum for this kind of question; we have a separate servlet forum, so someone will probably move this question there.

The javadocs of the Servlet interface talk about this - destroy is called once for each call to init, i.e. not for each call to service.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Servlets forum.

Dave
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The destroy method is called when the servlet is taken out of service.
There is a link to the servlet spec in my signature. It is the best reference for questions like this.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!