Reduce JSP compile time

Note: The feature to help reduce JSP compile times is only available in WAS V5.0.2.3. See WebSphere PTF Information Link outside Information Center (http://www.ibm.com/servers/eserver/iseries/software/websphere/wsappserver/services/service.htm) for more information on available PTFs.

When WAS compiles a JSP, it creates a large classpath that includes every WebSphere Application Server .jar file to ensure that any class referenced by a given JSP is found. The greater the number of .jar files and classes on the classpath, the longer it takes for a JSP to compile.

However, most JSPs only invoke a few WAS APIs, which makes the large classpath unnecessary. In WAS for iSeries, there is a new feature that helps reduce JSP compile times. You can now edit the classpath that is used for compiling JSPs in your application.

Note: This feature only controls the classpath for compiling your JSP. The environment used to load and run your JSP remains unchanged.

The feature to reduce compile times is controlled by a JSP initialization parameter. This gives you control over the JSP compile classpath on each web module.

Name:
jsp.compile.classpath

Value:
A space-separated list of paths. If a path contains a space, put quotation marks around the path. Paths that are not fully qualified are resolved to the web module directory during run time.

Configuration
There are several ways to configure the jsp.compile.classpath feature:

  1. To configure the jsp.compile.classpath feature using the Application Server Toolkit (recommended), perform the following steps:

    1. Start the Application Server Toolkit.
    2. In the J2EE perspective, expand Web Modules, and right click the Web module you want to modify.
    3. Select Open With --> Deployment Descriptor Editor.
    4. In the Web Deployment Descriptor, click the Extensions tab.
    5. On the WebSphere Extensions page, click Add under the JSP Attributes heading.
    6. Set the value of Name to jsp.compile.classpath.
    7. Set the value of Value to the desired classpath. See Determine the classpath to use for more information on setting the correct classpath.
    8. Click File --> Save.
    9. Deploy and start your application.
    10. Verify that the modified classpath is being used. To do this, look at the /QIBM/UserData/WebAS5/Base/instance/logs/server/SystemOut.log file. Once you start your application, a message similar to the following appears in the log:
      JSP Processor in webapp [Default Web Application] Using compile classpath
      [/QIBM/ProdData/WebAS5/Base/lib/webcontainer.jar:/QIBM/ProdData/WebAS5/
      Base/lib/j2ee.jar:/QIBM/UserData/WebAS5/Base/default/installedApps/server/
      DefaultApplication.ear/DefaultWebApplication.war/WEB-INF/classes:]

      Note: This message is given because the jsp.compile.classpath is set to an empty-string value.

  2. To configure the jsp.compile.classpath feature on an installed application using a text editor, perform the following steps:

    1. Edit the /QIBM/UserData/WebAS5/Base/instance/config/cells/cell-name/applications/
      MyEnterpriseApplication.ear/deployments/MyEnterpriseApplication/MyWebApplication.war/
      WEB-INF/ibm-web-ext.xmi file (where instance is the name of your application server instance and cell-name is the name of your cell).
    2. Add the following jspAttribute to the file:
      name="jsp.compile.classpath" value="classpath"
      where classpath is the value of the desired classpath. See Determine the classpath to use for more information on setting the correct classpath. For example, your file should look like the following:
      <?xml version="1.0" encoding="UTF-8"?>
        .
        .
        .
        <jspAttributes xmi:id="JSPAttribute_1" name="jsp.compile.classpath" value=""/>
      </webappext:WebAppExtension>
      
    3. Save the updated file.
    4. Copy the updated file to /QIBM/UserData/WebAS5/Base/installedApps/MyEnterpriseApplication.ear/
      MyWebApplication.war/WEB-INF. Replace the old version of the file with the modified version.
    5. Restart your enterprise application in the administrative console.
    6. Verify that the modified classpath is being used. To do this, look at the /QIBM/UserData/WebAS5/Base/instance/logs/server/SystemOut.log file. Once you start your application, a message similar to the following appears in the log:
      JSP Processor in webapp [Default Web Application] Using compile classpath
      [/QIBM/ProdData/WebAS5/Base/lib/webcontainer.jar:/QIBM/ProdData/WebAS5/
      Base/lib/j2ee.jar:/QIBM/UserData/WebAS5/Base/default/installedApps/server/
      DefaultApplication.ear/DefaultWebApplication.war/WEB-INF/classes:]

      Note: This message is given because the jsp.compile.classpath is set to an empty-string value.

Determine the classpath to use:

Determining the classpath for compiling a JSP is similar to determining a classpath for a servlet or other type of Java file. Look at the classes that are referenced in the JSP source, and make sure that the class or the .jar file where the class is found is on the specified classpath. However, give special consideration to JSPs that use custom tags, because custom tags contain references to classes.

JSPs always require the webcontainer.jar and j2ee.jar files. JSPs are also likely to reference classes in a web application for custom tags and other application-specific criteria. For these reasons, the following paths are automatically prepended to the paths you specify for jsp.compile.classpath when your application is started:

It is likely that the above files are sufficient for your JSPs to compile, in which case you only need to specify an empty string for the jsp.compile.classpath value.

Use WAS variables for your classpath entries. For example, if you reference a WAS .jar file, such as /QIBM/ProdData/WebAS5/Base/lib/admin.jar, you can use the WAS_LIBS_DIR variable, which changes your classpath entry to ${WAS_LIBS_DIR}/admin.jar

Example: Determine classpath and configure jsp.compile.classpath

The following JSP references com.ibm.websphere.cache.CacheEntry, com.mycompany.somepackage.MyClass, and com.mycompany.earlevel.EarClass:

<% com.ibm.websphere.cache.CacheEntry entry = null; %>
<% com.mycompany.somepackage.MyClass object = null; %>
<% com.mycompany.earlevel.EarClass object2 = null; %>

Three classes are referenced:

The file mywebjar.jar is automatically added to the classpath because it exists in the WEB-INF/lib directory. However, dynacache.jar and myearjar.jar must be explicitly added to the classpath. The JSP initialization parameters are now as follows:

Name:
jsp.compile.classpath

Value:
${WAS_LIBS_DIR}/dynacache.jar ${APP_INSTALL_ROOT}/node/MyEnterpriseApplication.ear/myearjar.jar (where node_name is the name of your application server node, MyEnterpriseApplication.ear is the name of your enterprise application, and myejbjar.jar is the name of your Java archive file).

Note: The space separator is used between paths (not a colon).