can i call destroy() method in init() method of servlet

Answer Posted / sunil jaiswal

Yes, we can call destroy method from init method without any worry. Destroy method will be called up as calling any other method. Request shall still be process afterwards through service method(doGet, doPost etc). Because calling destroy method doesnt mean the killing the servlet instance. Calling the init, service and destroy method is in the specification of servlet lifecycle. So we can not alter those specification through outside. Once the servlet container thinks the servlet is of no use at some time(at the server shutdown) the container surely will be calling up the destroy method prior to destroy the servlet instance.

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a jsp be called using a servlet?

580


Can we override servlet service method?

585


What is servlet looping or chaining?

658


What do you mean by session tracking and also explain its techniques?

498


Explain how to improve Servlet Performance?

596






What do you mean by filter in servlet?

538


How forward () method is different from send redirect () method?

515


How can the referrer and the target urls be used in servlet?

532


What are the life cycle methods of the servlet?

578


explain the advantages of servlet life cycle?

557


What are the servlet events?

592


List the Different types of servlet?

584


What is a server side include (ssi)

568


What is servlet mapping?

601


What are the uses of servlet and what is servlet chaining?

559