The Java EE 5 Tutorial

Translation and Compilation

During the translation phase each type of data in a JSP page is treated differently. Static data is transformed into code that will emit the data into the response stream. JSP elements are treated as follows:

In the Application Server, the source for the servlet created from a JSP page named pageName is in this file:


For example, the source for the index page (named index.jsp) for the date localization example discussed at the beginning of the chapter would be named:


Both the translation and the compilation phases can yield errors that are observed only when the page is requested for the first time. If an error is encountered during either phase, the server will return JasperException and a message that includes the name of the JSP page and the line where the error occurred.

    After the page has been translated and compiled, the JSP page’s servlet (for the most part) follows the servlet life cycle described in Servlet Life Cycle:

  1. If an instance of the JSP page’s servlet does not exist, the container:

    1. Loads the JSP page’s servlet class

    2. Instantiates an instance of the servlet class

    3. Initializes the servlet instance by calling the jspInit method

  2. The container invokes the _jspService method, passing request and response objects.

If the container needs to remove the JSP page’s servlet, it calls the jspDestroy method.