Author and all-around good cowpoke
Joined: Mar 22, 2000
The init and destroy methods are there for the servlet container to use. You can certainly call them but it would make no sense to do so. What is it that you think you could accomplish? Bill
Joined: Aug 03, 2002
I was just curious as this was asked to in the interview. and can yopu please through some more light on this as when init() will be explicitly called, I mean how can we perform this thing.
Joined: Nov 01, 2002
Init is called by the servlet container when the container (init)ially loads the servlet (e.g. when the app server instance is started or the application is deployed and restarted). From this you can guess what destroy does. This is why Mr. Brogden asked what you hope to accomplish by doing this? Generally, these methods perform application specific tasks in relation to start up and destruction like load static data from a database and store it in the application context. If you have a need for this data, you would put it into the init method. Since this has already been done, there would be no need to call it again. It's best to leave these methods for startup and destructrion as their name imply. Anything else you should create a new method in the servlet or even better implement it in a utility class.
No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?