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 meant by a web application
What is servlet container. how it works?
What is difference between jsp and servlet?
What is the web server used for running the Servlets?
What do you mean by scope object and what are its types?
Why doesn’t a servlet include main()? How does it work?
What is servlet in tomcat?
What are the various ways of session supervision in servlets?
Why don't we write a constructor in a servlet?
Write a hello world program using servlets.
Why is Servlet so popular?
Which HTTP method is non-idempotent?
What is the advantage of Servlets when compared with other server side technologies?
Explain is servlet mapping?
Which exception is thrown if the servlet is not initialized properly?