Servlet gets initialized in following two ways 1)Invoke corresponding constructor 2)Call init()
What I want to know is when do container go for these options ie when do container use option 1 and when do container use option 2
~ Pratibha Malhotra<br /> <br />Sun Certified Java Programmer<br />SCEA 1.4 (In Progress)<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />"Many of life's failures are people who did not realize how close they were to success when they gave up!!"
They both happen as part of the servlets life cycle. The whole life cycle is as follows
1) the servlet is loaded into the jvm 2) constructor is called 3) init(ServletConfig) is called by the container (this calls init() which you can override) 4) container calls service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException for every request it receives for the servlet 5) when the container is about to go down it calls destroy()