JSP Life Cycle

JSP life cycle

The life cycle of JSP page internally implemented as a Servlet. These are the following stages through which a JSP page has to pass:

  • Translation – This is an initial phase of JSP lifecycle that exist when first request of the JSP page is made. In this phase, web container translates the JSP page into servlet class.
  • Compilation – As soon as the JSP page is translated, web container compiles the servlet class. Both translation and compilation have been proceeded only when JSP page's servlet is older than JSP page.
  • Loading and Instantiating – Once the translation and compilation have been done, JSP page servlet follows the Servlet lifecycle. Hence, class is loaded and instance is created.
  • Execution – In this phase, the actual task is performed. Web container invokes jspInit() method to initialize servlet instance. To pass request and response objects, web container invokes jspService() method.
  • Destruction – This is the final phase of lifecycle in which web container invokes jspDestroy() method to remove JSP page servlet, if it is no more further required.
Features Some key features of JSP technology are as follows:
  • Portable - JSP is a platform independent technology. So, JSP web pages can run on any browser and web container independently.
  • Simple- It provides an easy way to develop and deploy web applications.
  • Powerful - JSP is a Java based technology. Thus, it is secured and robust.
  • Tag based approach - Instead of heavy bug of java code, JSP uses simple pre-defined tags.
  • Customized tag – JSP also allows users to define their own tag.

Related Topics

JSP Tutorial

Java Server Pages (JSP) is a server-side technology used to create static and dynamic web applications. The static content is expressed by text-based format files such as HTML, XML, SVG...

2 minutes read.

JSP Taglib Directive

Taglib directive is used to define tag libraries in JSP page. It enables user to use custom tags within JSP file. A JSP page can contains more than one taglib...

1 minute read.

JSP Comments

JSP provides separate tag for comment section. The content inside these tag is completely ignored by JSP engine.    The syntax of comment tag is mentioned below. <%-- This is a comment...

1 minute read.

JSP Implicit Objects

In JSP, implicit objects are pre-defined objects, created by the web container. These objects are created during the translation phase from JSP to Servlet. JSP allows you to call these...

1 minute read.

JSP out

In JSP, out is an implicit object that is associated with the response object. This object is used to write content to the output stream. Methods of JSP out Following are...

1 minute read.

JSP Scriptlet Tag

JSP scriptlet tag allows you to insert programming logic inside JSP page. Hence, you can put valid Java code within scriptlet tags. Each Java statement must be followed by a...

1 minute read.

JSP pageContext

The object pageContext is used to access all the information of JSP page. It is an instance of javax.servlet.jsp.PageContext. The scope of pageContext can be defined explicitly. The object is valid...

2 minutes read.

JSTL Core Tags

In JSTL, core tags are most frequently used tags that provides variable support, manages URL and control the flow of JSP page. To use JSTL it is required to associate...

2 minutes read.

JSP Expression Tag

JSP expression tag allows you to place the result of Java expression in a convenient way. It can be seen as an alternative of out.print() method. Thus, if we want to...

1 minute read.

JSP session

In JSP, session object is used to establish a connection between a client and a server. It maintains the state between them so that server recognize the user easily. The session...

1 minute read.

JSP EL Implicit Objects

Apart from operators, JSP also provide expression language implicit objects. The role of these implicit objects is to get the attribute associated with various object. Here, is the list of...

1 minute read.

JSTL XML Tags

In JSTL, XML tags are used for creating and manipulating xml documents. The following syntax represent the URL of XML tag: - <%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> To utilize the functionality of...

1 minute read.

JSP application

JSP application object is an instance of servlet's ServletContext interface. It is used initialize parameter of one or more JSP pages in an application. Thus, the scope of application object...

1 minute read.

JSP Declaration Tag

JSP declaration tag is used to declare variables and methods in JSP page. Unlike scriptlet tag, JSP container placed the content of declaration tag outside the jspService() method. So, variables...

1 minute read.

JSP useBean, getProperty and setProperty tags

Java bean is a special type of Java class that contains private variables and public setter and getter methods. Java bean class implements Serializable interface and provides default constructor. JSP allows...

1 minute read.

JSP Cookie Handling

Cookie is a small piece of information sent by server to recognize the user. This information is stored at client side in the textual form. In JSP, cookie is an object...

1 minute read.

JSP Request

The request object is used to fetch the user's data from the browser and pass this data to the server. The working of JSP request object is similar to the...

1 minute read.

JSP Action Tags

As the name implies, JSP action tags are used to perform various actions during the execution of JSP page. Here, each action performs some specific task. These tasks include:  Forwarding the...

1 minute read.

JSTL Formatting Tags

In JSTL, the role of formatting tag is to specify the type of format that represents date and time. The following syntax represent the URL of formatting tag: - <%@ taglib...

1 minute read.

JSP page

In JSP, the purpose of page object is to create the servlet instance. The role of page object is similar to this keyword in Java. The page object represents the entire...

1 minute read.