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
What is Client-Server Computing?
How to handle exceptions thrown by application with another servlet?
How do you define a servlet?
Why servlet is faster than jsp?
What is load-on-startup in servlet?
What is difference between ServletResponse sendRedirect() and RequestDispatcher forward() method?
Can a jsp be called using a servlet?
What's the architecture of a servlet package?
Explain the difference between servlet and cgi?
Which java application server is the best?
What are the differences between forward() method and sendredirect() methods?
Can you send an authentication error from a servlet?
What is SingleThreadModel interface?
What do you mean by session tracking and also explain its techniques?
Explain the different ways for servlet authentication?