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
Who is responsible to create the object of servlet?
How can we upload the file to the server using servlet?
What is httpservlet and how it is different from genericservlet?
What is the
Define the life cycle of a servlets.
Write the code to get the server information in servlet.
What are the exceptions thrown by servlets? Why?
What is MIME Type?
What is the difference between forward () and sendredirect () functions in servlet? Explain
What is servlet instance?
What is the use of welcome-file-list?
What is the difference between sendredirect() and forward() in a servlet?
What is servlet? Explain
What are the type of protocols used in httpservlet?
Explain jsessionid and when is it created?