• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Life Cycle-Destroy method

 
Mohan Chandrasekaran
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

Could you please explain under what circumstances a Servlet Container calls Destroy() method on a servlet instance?

Also could explain how a Servlet container maintains a pool of servlet instances, and how many servlet instances it creates on reading deployment descriptor?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your first question is answered by the javadocs for the Servlet interface.

As to the second question question, that is up to the servlet container to some degree. The spec demands that for all servlets having load-on-startup elements at least one instance is created. The container is free to create instances of the other servlets as well, or more than one instance for any servlet, but that's up to the implementation. I think it would be unusual for a container to take either of those actions, though. In particular, unless a servlet implements SingleThreadModel, no more than one instance is created (i.e., no pooling happens).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic