• jsp engine controls the life cycle of jsp
  • Jsp life cycle is described by three life cycle methods and six life cycle phases

Jsp life cycle methods :

  • jspInit()
  • _jspService()
  • jspDestroy()
Jsp Life Cycle

  • Jspinit() method is invoked when JSP page is initialized.
  • The _jspService() method corresponds to the body of the jsp page.
  • This method is defined automatically by the JSp container and should never be defined y the JSP page author.

Jsp Life cycle Phases: 

  • Translation phase
  • Compilation phase
  • Instantiation phase
  • initialization phase
  • Servicing phase
  • Destruction phase

Jsp Life Cycle methods

  • Jsp engine calls jspInit() method only once during the initialization phase of a jsp.
  • similarly during destruction phase jsp engine calls jspDestory() method only once
  • For each client request Jsp container calls _jspService() method once.

Jsp Translation phase:

  • When client request comes for a jsp for the first time , jsp engine makes a full read of the jsp verifies the syntactical corectness of the jsp elements and converts code into a servlet source code .
  • The process of JSP engine translating jsp into servlet nothing but translation phase of JSP.
  • Therefore , we say that Jsp development is another style of development  asking container to develop the servlet is nothing but JSP developement
  • Container generated servlet class is also known as page implementation class.

Jsp Compilation phase:

  • The process of jsp engine compiling the page implementation class is nothing but compilation phase of jsp.
  • Jsp engine uses JASPER compiler to compile the container generated servlet class source code.
  • In the life of the Jsp Translation and compilation happens only once unless jsp source code modified.

Jsp Instantiation phase:

  • Container creating the instance of generated servelt class is nothing but instantialtion phase of jsp
  • actually now we have a servelt object.
  • Servlet engine loads user user defined servlet class file from secondary memory into
    primary memory dynamically

    class c= class.forName("name");
  • Servlet engine creates the instance of loaded servlet class.
  • Servlet engine uses the following piece of code to load the servlet clas  dynamically to instantiate it.
    Class c= class.forName("Servlet class name");


  • Servlet engine creates servletConfig object
  • Servlet engine calls the init() method on the servlet instance by supplying servletconfig object
    as argument.
  • Once init method completely executed servlet is ready to serve the client request.

Servicing : 

  • Servlet engine creates servlet request and servlet response object based on the web server
    provided client information.
  • Servlet engine calls service method on the servlet instance by supplying two object reference as arguments
  • Once service method is completely executed , client request is served and request-response cycle is complete.
  • Within the service method request object is used to capture the user input
  • Response object is used to build the dynamic page and hand over the same to the web server


  • Destruction phase of servlet represents servlet being removed from use by container

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
Newer Post
Older Post

No comments

Leave a Reply

Select Menu