What are the life-cycle methods for a servlet?

Method Description
public void init(ServletConfig config) It is invoked only once when first request comes for the servlet. It is used to initialize the servlet.
public void service(ServletRequest request,ServletResponse)throws ServletException,IOException It is invoked at each request.The service() method is used to service the request.
public void destroy() It is invoked only once when servlet is unloaded.
Posted on by