Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

IBM WebSphere Developer Technical Journal: JavaServer Pages in WebSphere Application Server Technology for Developers V6 -- Part 2

Performance tuning the JSP engine

Scott Johnson (scottjoh@us.ibm.com)IBM WebSphere Application Server Development
Scott Johnson is the Team Lead for the WebSphere Application Server JSP engine. He joined IBM at the Research Triangle Park Lab in 2000, after 17 years as a programmer and project lead.

Summary:  The JavaServer Pages (JSP) engine in WebSphere Application Server Technology for Developers (TD) V6 can be configured for optimal performance in both a production server environment and a development environment. This article, the second in a three-part series, explores the performance-related configuration options available in the WebSphere Application Server V6 TD JSP engine.

Date:  17 Mar 2004
Level:  Intermediate
Also available in:   Chinese

Activity:  11197 views
Comments:  

Introduction

Part 1 of this article series on JavaServer Pages (JSP) in WebSphere® Application Server Technology for Developers (TD) V6 described the internal operations, configuration parameters, and process of the batch compiler, showing how batch compilation of JSPs in a predeployed application simplifies the deployment process and improves run time performance. Part 2 focuses on performance. In this article, we will take a close look at the performance tuning options available for the JSP engine in IBM WebSphere Application Server V6 TD which can be used to configure both production and development environments for optimal performance.

JSP engine configuration parameters

Many configuration parameters are available for the JSP engine in WebSphere Application Server 6.0 TD. Table 1 lists them all. In this article, we will concentrate on the parameters that relate to performance. These parameters (which appear bold in Table 1) are:

  • reloadEnabled
  • reloadInterval
  • disableJspRuntimeCompilation
  • trackDependencies
  • useThreadTagPool
  • usePageTagPool
  • keepgenerated
  • useJikes.

Table 1. JSP engine configuration parameters
Parameter NameDescriptionValuesDefault
compileWithAssertSpecifies whether the generated Java™ classes should contain support for the JDK 1.4 assertion facility. When true, the -source 1.4 option is passed to the Java compiler.true or falsefalse
classdebuginfoIndicates that the compiler should include debugging information in the generated classfile. When set to true, the -g option is passed to the Java compiler.true or falsefalse
deprecationIndicates the compiler should generate deprecation warnings when compiling the generated Java source. When set to true the -deprecation option is passed to the Java compiler.true or falsefalse
disableJspRuntime CompilationIf this option is set to true, the JSP engine at run time will not translate and compile JSP files; the JSP engine will load only precompiled classfiles. JSP source files do not need to be present in order for the classfiles to be loaded. With this option set to true, an application can be installed without JSP source, but must have precompiled classfiles. There is a Web container custom property of the same name that can be used to determine the behavior of all Web modules installed in a server. If both the Web container custom property and the JSP engine option are set, the JSP engine option takes precedence.true or falsefalse
extendedDocumentRootTo allow a JSP resource to be shared across Web application archives, specify a comma-delimited list of directories and/or JAR files as search paths to be used if the requested resource cannot be located in the Web application archive's public document tree.
(If the JSP is located inside a JAR file, the JAR file's timestamp will be used for isOutDated checks for recompile purposes if reloadEnabled is true.)
A comma-delimited list of directories and/or JAR filesnull
ieClassIdIndicates the Java plugin COM class ID for Internet Explorer. The <jsp:plugin> tags use this value.classidclsid:8AD9C840-044E-11D1-B3E9-00805F499D93
jsp.file.extensionsFor JSP files with extensions other than the four standard extensions (see default values) the extensions may be configured using this parameter. These extensions will be added to the standard extensions.
(The preferred method for doing this is to create a <jsp-property-group> in web.xml, and add a <url-pattern> tag for each extension.)
A colon- or semi-colon-separated list of file extensions that should be handled by the JSP engine. It is in the form of *.ext1; *.ext2: *.extn...The standard extensions handled by the JSP engine are:
*.jsp
*.jspx
*.jsw
*.jsv
keepgeneratedIndicates that the Java files generated by the JSP compiler during the translation phase of the processing should be retained.true or falsefalse
keepGeneratedclassfiles Indicates that the classfiles generated by the JSP compiler during the translation phase of the processing should be retained. true or falsetrue
reloadEnabledDetermines whether or not a JSP file will be translated and compiled at run time if the JSP file or its dependencies (see trackdependencies) are modified. If false, a JSP is still compiled, if necessary, on the first request to it, unless the disableJspRuntimeCompilation parameter is true.true or falsefalse
reloadIntervalIf reloading is enabled, this parameter determines how many seconds between requests for a JSP the engine will wait before checking to see if reloading the JSP is necessary.integer number of seconds5
scratchdirSpecifies the directory where the generated classfiles are created.
(The system property com.ibm.websphere.servlet.temp.dir can be used to set the scratchdir option on a server-wide basis. The JSP engine scratchdir parameter takes precedence over the system property com.ibm.websphere.servlet.temp.dir)
full path to the scratchdir directory[WAS_INSTALL_ROOT]/temp
trackDependenciesIf reloading is enabled, this parameter determines whether or not the JSP engine will track modifications to the requested JSP's dependencies as well as to the JSP itself. The three types of dependencies tracked by the JSP engine are:
  1. files statically included in the JSP.
  2. tag files that are referenced in the JSP (excluding tag files that are in JARs).
  3. tag library descriptors (TLD) that are referenced in the JSP (excluding TLDs that are in JARs).
true or falsefalse
useImplicitTagLibsThe JSP engine implicitly recognizes tsx and jsx as taglibrary prefixes for taglibraries supplied by the engine. If tsx and/or jsx are used as prefixes for a cutomer's taglibrary, the customer's taglibrary will override the implicit taglibrary. However, the implicit taglibrary will still be cached by the JSP engine. Explicitly setting this parameter to false will tell the engine to not cache the implicit taglibrary, and save resources.true or falsetrue
useJikesSpecify whether Jikes should be used for compiling Java sources. (Jikes is not shipped with WebSphere Application Server.) true or falsefalse
usePageTagPoolEnables or disables the reuse of custom tag handlers on an individual JavaServer Page basis.*true or falsefalse
useThreadTagPoolEnables or disables the reuse of custom tag handlers on a per request thread basis.*true or falsefalse
verboseIndicates the compiler should generate verbose output when compiling the generated Java source code. The effect of setting this parameter to true is that the -verbose option is passed to the Java compiler.true or falsefalse

* Enabling custom tag handler reuse might reveal problems in tag handler code with regard to the tag's ability to be reused. A custom tag handler should always do two things:

  1. The release() method of the tag handler should reset its state and release any private resources that it might have used. The JSP engine guarantees the release() method will be called before the tag handler is garbage collected.
  2. In the doEndTag() method, all instance states associated with this instance must be reset.

How to configure the JSP engine parameters

WebSphere Application Server does not support the modification of deployment descriptor extension parameters through either the administrative console or admin scripting. However, this is something you will want to be able to do, so in this section we will describe a way for you to add, change and delete JSP engine configuration parameters.

JSP engine configuration parameters are stored in a Web module's configuration directory, in the WEB-INF/ibm-web-ext.xmi file. An example of a configuration directory is:

{WAS_ROOT}/config/cells/cellname/applications/enterpriseappname/deployments/ deployedname/webmodulename

If an application was deployed into WebSphere Application Server with the Use Binary Configuration flag set to true, then the WEB-INF/ibm-web-ext.xmi file will be in a Web module's binaries directory instead of the configuration directory. An example of a binaries directory is:

{WAS_ROOT}/installedApps/nodename/EnterpriseAppName/WebModuleName/

The entry for a JSP engine configuration parameter in WEB-INF/ibm-web-ext.xmi would look like this:

<jspAttributes xmi:id="JSPAttribute_6"name "keepgenerated" value="true"/>

Listing 1 shows a sample ibm-web-ext.xmi file. The bold lines represent JSP engine configuration parameters.

Listing 1. Sample ibm-web-ext.xmi file

<?xml version="1.0" encoding="UTF-8"?>
<webappext:WebAppExtension xmi:version="2.0" xmlns:xmi=http://www.omg.org/XMI
    xmlns:webappext="webappext.xmi" xmlns:webapplication="webapplication.xmi" 
    xmi:id="WebAppExtension_1" reloadInterval="9" reloadingEnabled="true" 
    defaultErrorPage="error.jsp" additionalClassPath="" fileServingEnabled="true"
    directoryBrowsingEnabled="false" serveServletsByClassnameEnabled="true" 
    autoRequestEncoding="true" autoResponseEncoding="false">
    <webApp href="WEB-INF/web.xml#WebApp_1"/> 
    <jspAttributes xmi:id="JSPAttribute_1" name="useThreadTagPool" value="true"/>
    <jspAttributes xmi:id="JSPAttribute_2" name="verbose" value="false"/>
    <jspAttributes xmi:id="JSPAttribute_3" name="deprecation" value="false"/>
    <jspAttributes xmi:id="JSPAttribute_4" name="reloadEnabled" value="true"/>
    <jspAttributes xmi:id="JSPAttribute_5" name="reloadInterval" value="5"/>
    <jspAttributes xmi:id="JSPAttribute_6" name="keepgenerated" value="true"/>
    <!-- <jspAttributes xmi:id="JSPAttribute_7" name="trackDependencies" 
		value="true"/> -->
</webappext:WebAppExtension>

To add a JSP engine configuration parameter:

  1. Open the file for editing.
  2. Add a parameter line, then set the parameter and the desired value, following the example in Listing 1. Note that the integer n in JSPattribute_n has to be unique within the file.
  3. Save the file and restart the server so the parameter will take effect.

To remove a configuration parameter:

  1. Open the file for editing.
  2. Either delete the desired line entirely, or comment it out by surrounding the line with standard comment tags, as shown in the trackDependencies attribute line in Listing 1.
  3. Save the file and restart the server.

In Listing 1, WebAppExtension_1 contains reloadInterval="9" reloadingEnabled="true". In WebSphere Application Server V5, these attributes control both servlet and JSP reloading. However, in WebSphere Application Server V6 TD, they do not control JSP reloading.

Configuring the reloading of JSPs

Correctly configuring the reloading of JSPs for a particular environment is critical to JSP engine performance, regardless of whether it be for production or development. Table 2 shows the recommended settings for the associated parameters.


Table 2. Recommended reload settings for production and development environments
Recommended Settings
Configuration AttributeProduction EnvironmentDevelopment Environment
reloadEnabledfalsetrue
reloadIntervaln/a
(ignored if reloadEnabled is false)
~5 seconds
trackDependenciesn/a
(ignored if reloadEnabled is false)
true
Alternatively, set this to false to improve response time if dependencies aren't changing.
disableJspRuntimeCompilationtrue
Alternatively, set this to false if JSPs are not precompiled, and therefore need to be compiled on the first request.
false

JSP reloading

JSP reloading is activated via the reloadEnabled parameter:

<jspAttributes xmi:id="JSPAttribute_1" name="reloadEnabled" value="true"/>

The reloadEnabled attribute determines whether or not a JSP file will be translated and compiled at run time if the JSP file or its dependencies are modified (if trackDependencies is true). If reloadEnabled is false, a JSP is still compiled on the first request to it, if necessary, unless the parameter disableJspRuntimeCompilation is true. For example, if a classfile is older than its JSP source file, the JSP is compiled on the first request even if reloadEnabled is false. It will not be compiled on subsequent requests -- even if the JSP source file is modified or the class file is deleted -- unless reloadEnabled is true.

Reload interval

The reload interval is set via the reloadInterval parameter:

<jspAttributes xmi:id="JSPAttribute_1" name="reloadInterval" value="5"/>

If reloading is enabled, reloadInterval determines how many seconds between requests for a JSP the engine will wait before checking to see if reloading of the JSP is necessary. Once the reloadInterval is exceeded, reload checking will be performed and the reload interval timer will be reset to 0.

Let us use an example where the reloadInterval is set to 10. This reload interval is applied to each JSP individually, which means the reloading of modified JSPs will not all occur at the same time. After a given JSP is requested, 10 seconds will pass before the JSP engine will check during the next request to that JSP to see if that JSP has been modified and needs reloading. Once this check is made (whether or not the JSP actually needs reloading) another 10 seconds will pass before the next check is made for that JSP. Since JSPs are requested at different times, the 10 second intervals will be staggered. Here is a simplified example:

  • At 10:00 jsp1.jsp is requested and executed for the first time.
  • Between 10:00 and 10:00:10, jsp1.jsp is requested 3 times. The engine will not do reload checking on any of these requests.
  • jsp1.jsp is next requested at 10:00:15. The 10 second reloadInterval has been exceeded by 5 seconds and the JSP engine checks to see if jsp1.jsp needs reloading and reloads it if necessary. The reloadInterval timer starts counting at 10:00:15 forjsp1.jsp.
  • At 10:02 jsp55.jsp is requested and executed for the first time.
  • Between 10:02 and 10:02:12, jsp55.jsp is requested 2 times. The engine will not do reload checking on any of these requests.
  • jsp55.jsp is next requested At 10:00:37. The 10 second reloadInterval has been exceeded by 25 seconds and the JSP engine checks to see if jsp55.jsp needs reloading and reloads it if necessary. The reloadInterval timer starts counting at 10:00:37 for jsp55.jsp.

A reload interval of 0 and reloadEnabled=true would effectively cause the JSP engine to check for reloading on every request to a JSP.

Dependency tracking

Dependency tracking is set via the trackDependencies parameter:

<jspAttributes xmi:id="JSPAttribute_1" name="trackDependencies" value="true"/>

If reloading is enabled, trackDependencies determines whether or not the JSP engine will track modifications to the requested JSP's dependencies, as well as to the JSP itself. Three types of dependencies are tracked by the JSP engine:

  • files statically included in the JSP.
  • tag files that are referenced in the JSP (excluding tag files that are in JARs).
  • TLDs that are referenced in the JSP (excluding TLDs that are in JARs).

An example of dependency tracking:

  • toplevel.jsp statically includes footer.jspf.
  • trackDependencies is true when toplevel.jsp is compiled.
  • The path to footer.jspf and the timestamp of footer.jspf are stored in the class file that is generated for toplevel.jsp .
  • footer.jspf is subsequently modified.
  • toplevel.jsp is requested and its reload interval has been exceeded.
  • The JSP engine compares the timestamp stored in the class file with footer.jspf's timestamp on disk. Since the timestamps are different, toplevel.jsp is compiled, picking up the modification to footer.jspf.
  • trackDependencies must be true at the time a JSP is compiled in order for dependency tracking to work. If a JSP is compiled when trackDependencies is false, then its class file will not contain any dependency information. Also, because a dependency's timestamp is stored in a JSP class file, dependency tracking will still work even if a modification is made to a dependency when the server is not running.

Disabling compilation

Disablement of run time compilation of JSPs is set via the disableJspRuntimeCompilation parameter:

<jspAttributes xmi:id="JSPAttribute_1" name="disableJspRuntimeCompilation" value="true"/>

If disableJspRuntimeCompilation is set to true, the JSP engine will not translate and compile JSP files at run time; the JSP engine will load only precompiled classfiles. JSP source files do not need to be present in order for the classfiles to be loaded. With this option set to true, an application can be installed without JSP source, but it must have precompiled classfiles. A Web container custom property of the same name can be used to determine the behavior of all Web modules installed in a server. If both the Web container custom property and the JSP engine option are set, then the JSP engine option takes precedence. Setting disableJspRuntimeCompilation to true automatically sets reloadEnabled to false.

The processing sequence pertaining to the reloading of JSPs when trackDependencies is false is shown in Figure 1. Figure 2 shows the additional processing that is performed when trackDependencies is true. You will see that the path taken when disableJspRuntimeCompilation is true is clearly the most efficient path.


Figure 1. Reload processing sequence when trackDependencies is false
Reload processing sequence when trackDependencies is false

When trackDependencies is true, the JSP engine performs additional file system access to determine if any of a JSP's dependencies have changed since the JSP was last translated and compiled. Figure 2 shows this additional processing, represented by the "No" path of the "Is JSP classfile outdated?" decision diamond.


Figure 2. Additional reload processing performed when trackDependencies is true
Additional reload processing performed when trackDependencies is true

Pooling classic tag handlers

Pooling of tag handlers is only available for classic tag handlers; pooling of simple tag handlers is not allowed by the JSP 2.0 specification. In WebSphere Application Server V6 TD, two types of classic tag handler pooling are available:

  • Page level pooling: configured by the usePageTagPool parameter.
  • Thread level pooling: configured by the useThreadTagPool parameter.

If both usePageTagPool and useThreadTagPool are set to true, page-based tag pooling is used.

When a custom action is used in a JSP, the JSP engine generates Java code to instantiate or reuse the class that implements the custom tag (the tag handler class). The JSP engine also generates Java code to manage the lifecycle of the tag handler. The sample code in Listing 2 shows a JSP page that uses six custom actions; this example will be referred to throughout this section.

Listing 2. Sample JSP source with custom actions

<%@ taglib uri="utility.tld" prefix="myTags" %>
<BR>
<myTags:repeat iterations="5">
	this is  tag #1!
</myTags:repeat>
<BR>
<myTags:repeat iterations="6" varName="xyz">
	this is  tag #2!
</myTags:repeat>
<BR>
<myTags:repeat iterations="2">
	this is  tag #3!
</myTags:repeat>
<BR>
<myTags:repeat iterations="9" varName="xyz">
	this is  tag #4!
</myTags:repeat>
<BR>
<myTags:repeat iterations="8" begin="7" >
	this is  tag #5!
</myTags:repeat>
<BR>
<myTags:repeat iterations="9" begin="6" >
	this is  tag #6!
</myTags:repeat>

Restrictions on tag handler reuse

Uniqueness

In order for a tag handler to be reused across custom actions, the custom actions must:

  • use the same tag handler class.
  • have the same set of optional attributes.

In the above sample JSP, the custom actions all use the same tag handler class, com.yourco.tags.RepeatTag, which implements the repeat custom action. However, the custom actions use different sets of attributes. The TLD (not shown), in which the repeat tag is defined, indicates that the iterations attribute is required, but the varName and begin attributes are optional. This means that in the sample JSP:

  • Tags 1 and 3 can reuse a single tag handler.
  • Tags 2 and 4 can reuse a single tag handler.
  • Tags 5 and 6 can reuse a single tag handler.
  • The tag handler reuse cannot be done across those sets of tags.

Enabling custom tag handler reuse might reveal problems in tag handler code with regard to the tag's ability to be reused. To avoid such problems, the custom tag handler developer should be sure to always make these provisions:

  • The release() method of the tag handler should reset its state and release any private resources that it might have used. The JSP engine guarantees the release() method will be called before the tag handler is garbage collected.
  • In the doEndTag() method, all instance states associated with this instance must be reset.

keepgenerated

Retention of generated Java source is configured with the keepgenerated parameter:

<jspAttributes xmi:id="JSPAttribute_1" name="keepgenerated" value="true"/>

The JSP engine will retain the Java source files it generates if the keepgenerated configuration parameter is set to true. (The code samples that follow were taken from Java source generated by the JSP engine, and retained because keepgenerated was set to true.)

When tag handler pooling is not used

When tag handler pooling is not used, a tag handler object must be instantiated on every invocation of a tag. Listing 3 shows the Java code generated for tags 1 and 3 in the sample JSP. The tag handler objects _jspx_th_myTags_repeat_0 and _jspx_th_myTags_repeat_2 are instantiated using new in both cases. The sample JSP page's six tags will each have separate tag handler objects, and they will be destroyed and garbage collected when the page execution finishes. Figure 3 illustrates tag handler creation when no tag pooling is used.

Listing 3. Generated tag handler code, without tag pooling

// code generated for tag #1
com.yourco.tags.RepeatTag _jspx_th_myTags_repeat_0 = new 
    com.yourco.tags.RepeatTag();
_jspx_th_myTags_repeat_0.setPageContext(pageContext);
_jspx_th_myTags_repeat_0.setParent(null);
_jspx_th_myTags_repeat_0.setIterations(5);
int _jspx_eval_myTags_repeat_0 = _jspx_th_myTags_repeat_0.doStartTag();

    BODY OF ACTION NOT SHOWN

// release() is called on the tag handler because its lifecycle is done
if (_jspx_th_myTags_repeat_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
    _jspx_th_myTags_repeat_0.release();
    return;
}
_jspx_th_myTags_repeat_0.release();
.. .. .. .. .. .. .. .. 
// code generated for tag #3
com.yourco.tags.RepeatTag _jspx_th_myTags_repeat_2 = new  
    com.yourco.tags.RepeatTag();
_jspx_th_myTags_repeat_2.setPageContext(pageContext);
_jspx_th_myTags_repeat_2.setParent(null);
_jspx_th_myTags_repeat_2.setIterations(2);
int _jspx_eval_myTags_repeat_2 = _jspx_th_myTags_repeat_2.doStartTag();

    BODY OF ACTION NOT SHOWN

// release() is called on the tag handler because its lifecycle is done
if (_jspx_th_myTags_repeat_2.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
    _jspx_th_myTags_repeat_2.release();
    return;
}
_jspx_th_myTags_repeat_2.release();


Figure 3. Tag handler creation when tag pooling is not used
Tag handler creation when tag pooling is not used

When Page-Level Pooling is Used

Page-level pooling is activated via the usePageTagPool parameter:

<jspAttributes xmi:id="JSPAttribute_1" name="usePageTagPool" value="true"/>

When page-level tag handler pooling is used, tag handlers may be reused among separate occurrences of a tag within a page, as described above under Restrictions on tag handler reuse. Listing 4 shows the Java code generated for tags 2 and 4 when usePageTagPool is true. Similar code would be generated for the two other tag handlers (for tags 1 and 3, and for 5 and 6). The result is that only three tag handler objects are created and destroyed during the execution of the JSP, instead of the six created and destroyed when tag pooling is not used. Figure 4 illustrates tag handler creation when page-level tag pooling is used.

In the _jspService method (Listing 4), an instance of each tag handler is created at the top, and each tag handler is then used when needed. The release() method is called on the handlers in the finally block at the bottom of the _jspService method, since their lifecycles are only complete at that point. The objects are garbage collected after the page finishes executing. A single tag handler is used multiple times and will be created and destroyed only once during a single request to the JSP page.

Listing 4. Sample tag handler code with page-level pooling

  public void _jspService(HttpServletRequest request, HttpServletResponse  response)
	  throws java.io.IOException, ServletException {
... ... ... ... ... ... ... ...
// An instance of each tag handler is created
// this handler is used for tags 1 and 3
	com.yourco.tags.RepeatTag _jspx_th_myTags_repeat_0 = new 
            com.yourco.tags.RepeatTag();
// this handler is used for tags 2 and 4
	com.yourco.tags.RepeatTag _jspx_th_myTags_repeat_1 = new 
            com.yourco.tags.RepeatTag();
// this handler is used for tags 5 and 6
	com.yourco.tags.RepeatTag _jspx_th_myTags_repeat_2 = new 
            com.yourco.tags.RepeatTag();
... ... ... ... ... ... ... ...
  // Tag handler for tag #2; the handler was created above
	  _jspx_th_myTags_repeat_1.setPageContext(pageContext);
	  _jspx_th_myTags_repeat_1.setParent(null);
	  _jspx_th_myTags_repeat_1.setIterations(6);
	  _jspx_th_myTags_repeat_1.setVarName("xyz");
	  _jspx_eval_myTags_repeat_1 = _jspx_th_myTags_repeat_1.doStartTag();

    BODY OF ACTION NOT SHOWN

	  if (_jspx_th_myTags_repeat_1.doEndTag() == 
             javax.servlet.jsp.tagext.Tag.SKIP_PAGE){
		return;
	  }
... ... ... ... ... ... ... ...
  // Tag handler for tag #4; the same handler used for tag #2 is reused here
	  _jspx_th_myTags_repeat_1.setPageContext(pageContext);
	  _jspx_th_myTags_repeat_1.setParent(null);
	  _jspx_th_myTags_repeat_1.setIterations(9);
	  _jspx_th_myTags_repeat_1.setVarName("xyz");
	  _jspx_eval_myTags_repeat_1 = _jspx_th_myTags_repeat_1.doStartTag();
	
    BODY OF ACTION NOT SHOWN
	  if (_jspx_th_myTags_repeat_1.doEndTag() == 
             javax.servlet.jsp.tagext.Tag.SKIP_PAGE){
		return;
	  }
... ... ... ... ... ... ... ...
  // Lifecycle of the tag handlers has ended, so release is called()
	} finally {
	  if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
	  if (_jspx_th_myTags_repeat_0 != null) _jspx_th_myTags_repeat_0.release();
	  if (_jspx_th_myTags_repeat_1 != null) _jspx_th_myTags_repeat_1.release();
	  if (_jspx_th_myTags_repeat_2 != null) _jspx_th_myTags_repeat_2.release();
	}
}// end of _jspService method


Figure 4. Tag handler creation when page-level tag pooling is used
Tag handler creation when page-level tag pooling is used

When Thread-Level Pooling is Used

Thread-level pooling is activated via the useThreadTagPool parameter:

<jspAttributes xmi:id="JSPAttribute_1" name="useThreadTagPool" value="true"/>

When thread-level tag handler pooling is used, tag handlers may be reused among separate occurrences of a custom action across all JSP pages in a single Web module across separate requests. Listing 5 shows the relevant Java code generated when useThreadTagPool is true. The only difference between the code generated for thread-level reuse and page-level reuse is in the initialization of the tag handlers at the top of the _jspService method and the code generated in the finally block at the bottom. Figure 5 illustrates tag handler creation when thread-level tag pooling is used.

The thread pool caches unique occurrences of tag handlers, with uniqueness as described above under Restrictions on tag handler reuse. For each unique tag found in all JSPs in a Web module, a tag handler is cached on the thread in which the JSP page was executing at the time the tag handler was encountered.

Threads are allocated by the Web container among all Web modules and a given thread may be reused across Web modules. The JSP engine's tag handler pooling mechanism guarantees that a tag cached in a given Web module will only be made available to JSP pages within that Web module, therefore avoiding ClassCastExceptions (since the tag handler object will be loaded by a classloader specific to a Web module).

(The pooling mechanism within getTagHanler() has been implemented with a single synchronization block whose code is only executed the first time a new thread is encountered, thereby minimizing the negative performance effects of synchronization.)

Listing 5. Creation of tag handler objects with thread-level pooling

  public void _jspService(HttpServletRequest request, HttpServletResponse  response)
	  throws java.io.IOException, ServletException {

... ... ... ... ... ... ... ...
// An instance of each tag handler is retrieved using the method getTagHandler()
// this handler is used for tags 1 and 3
	String _tagKey_myTags_repeat_0 = "com.yourco.tags.RepeatTag";
	com.yourco.tags.RepeatTag _jspx_th_myTags_repeat_0 = 
	(com.yourco.tags.RepeatTag)getTagHandler(request, _tagKey_myTags_repeat_0, 
	"com.yourco.tags.RepeatTag");
// this handler is used for tags 2 and 4
	String _tagKey_myTags_repeat_1 = "com.yourco.tags.RepeatTag_varName";
	com.yourco.tags.RepeatTag _jspx_th_myTags_repeat_1 = 
	(com.yourco.tags.RepeatTag)getTagHandler(request, _tagKey_myTags_repeat_1, 
	"com.yourco.tags.RepeatTag");
// this handler is used for tags 5 and 6
	String _tagKey_myTags_repeat_2 = "com.yourco.tags.RepeatTag_begin";
	com.yourco.tags.RepeatTag _jspx_th_myTags_repeat_2 = 
	(com.yourco.tags.RepeatTag)getTagHandler(request, _tagKey_myTags_repeat_2, 
	"com.yourco.tags.RepeatTag");
... ... ... ... ... ... ... ...
  // Tag handlers are returned to the pool; release() is called only when the the 
         //  web module is stopped and the tag handler pools for that web module are 
         //  cleared out.
	} finally {
	  if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
	  putTagHandler(request, _tagKey_myTags_repeat_0, _jspx_th_myTags_repeat_0);
	  putTagHandler(request, _tagKey_myTags_repeat_1, _jspx_th_myTags_repeat_1);
	  putTagHandler(request, _tagKey_myTags_repeat_2, _jspx_th_myTags_repeat_2);
	}
  }
}


Figure 5. Tag handler creation when thread-level tag pooling is used
Tag handler creation when thread-level tag pooling is used

Configuring the JSP engine to use Jikes

The Jikes Java compiler is activated via the useJikes parameter:

<jspAttributes xmi:id="JSPAttribute_1" name="useJikes" value="true"/>

When useJikes is true, the JSP engine will use the Jikes Java compiler instead of the default javac compiler from the JDK. Jikes is an open source compiler available here. Jikes is not shipped with WebSphere Application Server Technology for Developers V6.0, and is supported through IBM developerWorks. Jikes versions 1.8 and 1.9 have been tested with the JSP engine in WebSphere Application Server Technology for Developers V6.0 and work well.

In the JSP translation and compilation process, Jikes can result in better performance in the compilation step than the JDK's compiler.

Conclusion

The JSP engine in WebSphere Application Server V6 TD can be configured in three important ways, to best suit both production and development environments:

  • Reloading of classfiles when JSPs are modified.
  • Pooling of classic custom tag handler objects.
  • The use of the open source Jikes java compiler.

Part 3 will conclude this article series, when we examine the architecture of the JSP engine in WebSphere Application Server Technology for Developers V6.

Acknowledgements

The author wishes to thank Todd Kaplinger and Richard Backhouse for their contributions to this article.


Resources

About the author

Scott Johnson is the Team Lead for the WebSphere Application Server JSP engine. He joined IBM at the Research Triangle Park Lab in 2000, after 17 years as a programmer and project lead.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=13468
ArticleTitle=IBM WebSphere Developer Technical Journal: JavaServer Pages in WebSphere Application Server Technology for Developers V6 -- Part 2
publish-date=03172004
author1-email=scottjoh@us.ibm.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers