Java Servlet Lifecycle .

What about Servlets and Lifecycle?

  • When a Servlet is deployed to a Web server or Application server and needed for a service, the Servlet-contain in the server will load and instantiate the Servlet.
  • The Servlet-contain will then call the HttpServlet object init() method and stay ready for service of any client request.
  • As soon as a request for the servlet comes the Servlet-container will call the HttpServlet object service() method.
  • Through the HttpServlet object service() the Servlet-Container will call the correct doXXX method depending on the Request type (GET, POST ...).
  • Then the Servlet programmer code will be executed in a new Thread and the Servlet goes back to ready state waiting for a new request.
  • If there is no request to handle and a server-defined timeout is reached the Servlet-container calls the HttpServlet object destroy() method and removes the servlet from the container.


© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.