destroy() gets executed and the initialization process continues. It is a trick question in servlets interview.
In java servlet, destroy() is not supposed to be called by the programmer. But, if it is invoked, it gets executed. The implicit question is, will the servlet get destroyed? No, it will not. destroy() method is not supposed to and will not destroy a java servlet. Don’t get confused by the name. It should have been better, if it was named onDestroy().
The meaning of destroy() in java servlet is, the content gets executed just before when the container decides to destroy the servlet. But if you invoke the destroy() method yourself, the content just gets executed and then the respective process continues. With respective to this question, the destroy() gets executed and then the servlet initialization gets completed.
Have a look at this java servlet interview question: Servlet Life Cycle – Explain, it might help you to understand better.












this is good info. I have a question- This is not related to JSP. This is about threads. We have Object.wait() & Thread.sleep(). Why can not we have both in a single class or vice versa? or why wait() is in a Object class?
Superb joe keep going man….
Very nice documentation. My request to u is to Add Struts documentation also.
Hi Joseph,
These are great concepts on Java and J2ee.If can share your Struts and Hibernate [ hope you have ...must be]experience then it will be a great pleasure.
Thanks
Niraj
HI PARASNTH
the wait method id wait for one thred is completed and next thread is executed,her we don’t give any time.
where as sleep is , if u give some time. here one problem occur even the first thread is completed there process.next thread is execute,but before execute it will check time pried
Why it is named as java as java language?
It is technology.
Hi Prasanth,
Object.wait() does release the monitor ownership. But Thread.sleep() does not release the monitor ownership. which means thread.sleep() is resource intensive where object.wait() is not.
Hi,
Your way of explaination is excellent.
Thanks
Pingback: Java Pins
@ Divya ., Answer:- Bava ani pedithe bagundadhu kaabatti., in english., it is not fare if we called it as BAVA (brother in law) .. Dont ask silly questions., useless fellow
can u explain what is resource intensive ?
e.g. thread.sleep() is resource intensive.
plz explain..
This is really helpful, Better if you post some articles on springs and Web Services also.
why wait(),notify(),notifyAll() are declared in java.lang.Object instead of java.lang.Thread
Good article Joe i liked it very much
Pls give some knowledge about Struts
Very Good Explanation
really superb blog. hats off!!!
thanks joe
Your website Designing and logo presence and exposure is too much impressive………..Article so….