Can we call destroy() method on servlets from service method?

destroy() is a servlet life-cycle method called by servlet container to kill the instance of the servlet.

The answer to your question is "Yes". You can call destroy() from within the service(). It will do whatever logic you have in destroy() (cleanup, remove attributes, etc.) but it won't "unload" the servlet instance itself. That can only be done by the container

Showing Answers 1 - 2 of 2 Answers

hariprasad

  • Apr 22nd, 2006
 

destroy

  Was this answer useful?  Yes

rameshvdnv

  • Apr 25th, 2007
 

Yes,we can call destroy method,but it is not recommended to call this method from our code since init(),service(),destroy()'s r servlet lifecycle methods.
And in destroy()there will be aconfig variable which will be set to null if we override this method the methods which uses this config variable will fail.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions