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
How we can get ip address of client in servlet?
What is the directory structure of web application?
How can a servlet be used to generate plain text instead of html?
How servlets are deployed in java?
What's the difference between authentication and authorization?
What are session variable in servlets?
Which are the different ways you can communicate between servlets?
How do servlets work?
When to use doget() and when dopost()?
What is servlet lazy loading?
What are the different methods of session management in servlets?
What is the functionality of actionservlet and requestprocessor?
What is the default http method in the servlet?
What are the uses of servlet
What is a deployment descriptor?