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 servlet api used for conneting database?
What are the advantages of Servlet over CGI?
Explain the architechure of a servlet?
What is string tokenizer?
What is servlet name in web xml?
Explain web container.
What exception should be thrown when servlet is not properly initialized?
What’s the difference between genericservlet and httpservlet?
Explain how to improve Servlet Performance?
What is the use of servlet wrapper classes?
How would you create deadlock on your servlet?
Why is it that we can't give relative URL's when using ServletContext.getRequestDispatcher() when we can use the same while calling ServletRequest.getRequestDispatcher()?
What do you mean by request dispatcher in servlet?
What is a web container and what is its responsibility?
What do you understand by mime type?