1) init() – Servlet enters into this phase whenever first request for the servlet is requested by the client. Servlet gets initialized based on value in web.xml. If the value is 0 then it will be initialized on first client request otherwise it will be initialized on server startup
public void init(ServletConfig config) throws ServletException
2) service() – After initialization, the servlets serve clients on request, implementing the application logic of the web application they belong to. Servlet create separate threads for each client request. It determines the type of request, get or post and calls the appropriate method.
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
3) destroy()-If the servlet is no longer needed for servicing any request, the servlet container calls the destroy() method . Like the init() method this method is also called only once throughout the life cycle of the servlet. Calling the destroy() method indicates to the servlet container not to sent the any request for service and the servlet releases all the resources associated with it.
public void destroy() { }
public void init(ServletConfig config) throws ServletException
2) service() – After initialization, the servlets serve clients on request, implementing the application logic of the web application they belong to. Servlet create separate threads for each client request. It determines the type of request, get or post and calls the appropriate method.
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
3) destroy()-If the servlet is no longer needed for servicing any request, the servlet container calls the destroy() method . Like the init() method this method is also called only once throughout the life cycle of the servlet. Calling the destroy() method indicates to the servlet container not to sent the any request for service and the servlet releases all the resources associated with it.
public void destroy() { }
To view JSP Lifecycle, click here.
No comments:
Post a Comment