• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Every time should i call destroy()

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , am new bie to serlvet. my interview asked should i call destroy method every time. can you explain it
 
Mahen Rathod
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you don't need to call destroy() method. This method is called by servlet container when the servlet is getting destroyed. However you can override destroy() method for your business need.

Regards
Mahen
 
Fatih Keles
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you ask the question to google, there exists -at least one- an other thread on coderanch
http://www.coderanch.com/t/361928/Servlets/java/Servlet-Destroy-Method

and this is what servlet 2.1 api says:
http://java.sun.com/products/servlet/2.1/api/javax.servlet.Servlet.html#destroy()

But my concern is how the servlet container behaves? It is a black box most of the time.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But my concern is how the servlet container behaves? It is a black box most of the time.


The servlet container behaves according to the servlet API. Concealing the mechanics and allowing for different underlying code is exactly the purpose of stating the API in terms of interfaces as much as possible.

You can download the code for any of the open source implementations and learn a lot of Java by study of the actual implementations.

Bill


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic