JSP Tutorial || life cycle of JSP page.

The life cycle of JSP page is a process of converting JSP page to a servlet or in other words, you can say web container generates a separate file with (_jsp.java) extension. or you can say the complete execution of a JSP page.

Before this have a look at what is JSP.

JSP is Java server page. this technology is used to create dynamic web applications. JSP adds Java code inside HTML using JSP tags. We can do server-side programming using JSP as well as Html for client side. JSP allows us to write HTML code containing tags, inside which we can include powerful Java programs. Using JSP, one can easily separate Presentation and Business logic as a web designer can design and update JSP pages creating the presentation layer.

There is all step witch come in the life cycle of JSP page.

  • Translation or convert JSP into Servlet code.
  • Compilation of Servlet to bytecode.
  • Loading Servlet class.
  • Creating servlet instance.
  • Initialization by calling jspInit() method.
  • Request Processing by calling _jspService() method.
  • Destroying by calling jspDestroy() method.

JSP is an extended version of servlet so the life cycle of JSP is also same a servlet lifecycle but difference is only translation face.

 

                                                JSP Lifecycle

We can take an example for this Like I have (hello.jsp) file with following steps.

  1. web container translate this (hello.jsp) file in (.java) file.
  2. Compile into java servlet class and generate a bytecode(.class) file.
  3. Bytecode loaded by the class loader.
  4. Container creates an instance of that servlet class.
  5. Now for service request initialized servlet by jspInit().
  6. Web container call _jspService() method for each request.
  7. At the end jspDestroy() destroy the request.

Add a Comment

Your email address will not be published. Required fields are marked *

seventeen − fifteen =