A servlet's init(ServletConfig) method is called by the server immediately after the server constructs the servlet's instance. Depending on the server and its configuration, this can be at any of these times:
1.When the server starts 2.When the servlet is first requested, just before the service() method is invoked 3.At the request of the server administrator
In any case, init() is guaranteed to be called before the servlet handles its first request. The init() takes an object and gives it its servletness (by giving the servlet config).
Joined: Mar 02, 2008
Thanks,But this is with respect to init(ServletConfig).what about init()?
The javadocs of the GenericServlet.init() method mention when it will be called. Note that that method is not part of the Servlet interface, so the servlet container knows nothing about it - it is particular to the GenericServlet class.