Can we call destroy() method inside the init() method? What
happens when we do so?
Answer Posted / amitasite
One can call destroy method from init method. One scenario
in which you would like to call is some resource is looked
up once in init() method and cleaned in destroy() method. If
exception is thrown before it finishes as servlet is not
brought in service, container won't call destroy method. so
to keep resource clean you can call destroy() method from init()
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
What are the phases of the servlet life cycle?
What are some disadvantages of storing session state in cookies?
Is tomcat a servlet container?
Which method of the httpservletrequest object is used?
Explain the servlet context.
How we can get ip address of client in servlet?
Why do we need a constructor in a servlet if we use the init method?
What is the need of servlet filters?
What are the uses of servlets?
How does Cookies work in Servlets?
What is servlet? Explain
List out difference between a JavaBean from a Servlet?
List some life cycle methods of a servlet.
What are all the protocols supported by httpservlet?
List out the difference between ServletConfig and ServletContext?