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 is the use of send redirect () method?
What is the default http method in the servlet?
If a servlet is not properly initialized, what exception may be thrown?
What is servlet invoker?
What is the disadvantage of cookies?
Write a program to show the functionality of servlets.
What are the different methods involved in the process of session management in servlets?
What if you need to span your transaction across multiple servlet invocations?
Explain servlet life cycle?
What is load-on-startup in servlet?
What is the inter-servlet communication?
Why servlet is faster than jsp?
What do you mean by cgi and what are its drawbacks?
What is session tracking?
Can we fetch the attributes related to a servlet on a different servlet?