JSP compilation in WebSphere Application Server Community Edition

Technote (FAQ)


Question

How do I configure JSP compilation in WebSphere Application Server Community Edition?

Cause

WebSphere Application Server Community Edition uses Tomcat as the Web container. When Web applications containing JSPs are deployed on the server, WebSphere Application Server Community Edition uses Jasper to compile JSPs and stores the compiled JSPs in the following directory:

<wasce_home>/var/temp

By default, when the server is restarted, all the compiled JSPs are deleted. Consequently, the server has to recompile JSPs whenever any JSPs are accessed by users after the server is restarted. The following technote explains how to configure WebSphere Application Server Community Edition so that JSPs are compiled once and retained even after server is restarted.

Answer

  • Configuration at the server scope
    WebSphere Application Server Community Edition can be configured to retain the compiled JSPs of all Web applications running in the server across server restarts. The procedure is as follows.
    1. Open the following file in a text editor:

      <wasce_home>/var/catalina/conf/web.xml

    2. Add the following parameters to org.apache.jasper.servlet.JspServlet:

      <init-param>
      <param-name>scratchdir</param-name>
      <param-value>
         ../var/catalina/worker1/
      </param-value>
      </init-param>
      <init-param>
      <param-name>keepgenerated</param-name>
      <param-value>false</param-value>
      </init-param>

    3. Create a sub-directory named worker1 in the following directory:

      <wasce_home>/var/catalina/conf

    4. JSPs from all the Web applications are compiled once into worker1 directory and persisted across server restarts.

  • Configuration at the application scope
    If users want to configure retaining the compiled JSPs for a single Web application, the following procedure needs to followed.
    1. Open the web.xml file of the Web application in a text editor.

    2. Copy the following contents.

      <servlet>
      <servlet-name>jsp</servlet-name>
      <servlet-class>
        org.apache.jasper.servlet.JspServlet
      </servlet-class>
      <init-param>
        <param-name>development</param-name>
        <param-value>false</param-value>
      </init-param>
      <init-param>
        <param-name>fork</param-name>
        <param-value>false</param-value>
      </init-param>
      <init-param>
        <param-name>scratchdir</param-name>
        <param-value>
         ../var/catalina/worker1/
        </param-value>
      </init-param>
      <init-param>
        <param-name>keepgenerated</param-name>
        <param-value>false</param-value>
      </init-param>
      <init-param>
        <param-name>xpoweredBy</param-name>
         <param-value>false</param-value>
      </init-param>
      <init-param>
         <param-name>engineOptionsClass</param-name>
         <param-value>
            org.apache.geronimo.jasper.JspServletOptions
         </param-value>  
      </init-param>
        <load-on-startup>3</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jsp</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jspx</url-pattern>
      </servlet-mapping>

    3. Create a sub-directory named worker1 in the following directory:

      <wasce_home>/var/catalina/conf

    4. JSPs from the configured application are compiled once into worker1 directory and retained intact across server restarts.

  • JSP precompilation
    Before deploying Web applications on WebSphere Application Server Community Edition, users can precompile the JSPs into servlets using JASPER libraries shipped with the WebSphere Application Server Community Edition. A sample ANT script is available here. The ANT script can be configured to use JASPER libraries shipped with WebSphere Application Server Community Edition. This technique precompiles all the JSPs into servlets and generates required servlet mapping entries to be copied to the web.xml file of the Web application. The generated servlet classes can be packaged with the Web application and deployed on the server.

Rate this page:

(0 users)Average rating

Document information


More support for:

WebSphere Application Server Community Edition
Tomcat

Software version:

2.0, 2.0.0.1, 2.0.0.2, 2.0.0.3, 2.1, 2.1.0.1, 2.1.1.1, 2.1.1.2

Operating system(s):

AIX, Linux, Solaris, Windows

Software edition:

Elite, Enhanced, Entry

Reference #:

1303765

Modified date:

2008-05-09

Translate my page

Machine Translation

Content navigation