Servlet Tutorials

Life cycle of Servlets
Previous Home Next
adplus-dvertising

Life cycle of Servlets

  1. Loading Servlet Class : It is loaded which is first request for the servlet is received by the Web Container.
  2. Servlet instance creation :After this is loaded, Web Container creates a instance of it and it is created only once in the life cycle.
  3. Call to the init() method : init() method is called by the Web Container on servlet instance to initialize the servlet.
  4. Signature of init() method :
    public void init(ServletConfig config) throws ServletException
    
  5. Call to the service() method : In containers call the service() method to response servlet is received. This service() method to call the doGet() or doPost() methos based ont eh type of the HTTP request, as explained in previous lessons.
  6. Signature of service() method :
    public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
    
  7. Call to destroy() method: In this method to call web Container to destroy() or removing servlet instance.
Previous Home Next