• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Destroy

 
s rao
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will happen if I call destroy() method as a last statement of doGet() method.
Will it destroy the servlet??
Also when a servlet is being destroyed is the destroy() method first called or is finalize() called??
If anyone knows the answers for the above please let me know.
 
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
when you explicitly call the destroy method, the container executes it and makes the servlet instance to be Garbage collected.
regarding the finalize method, it is called when the servlet is about to be garbage collection. Agian the GC is not sure to be called everytime.When the resources are low GC thread will be called by the JVM.
So the Destroy method doesn't have any realtion with the Finalize method.
Usually Destroy methos is used to release some resources like, Database connections, network connections, files and so on.
Cheers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic