ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzatz_5.4.0.1/51/program/jspcompile.htm

180 lines
9.4 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
<title>Reduce JSP compile time</title>
</head>
<BODY>
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h4><a name="jspcompile"></a>Reduce JSP compile time</h4>
<p>When WebSphere Application Server 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.</p>
<p>However, most JSPs only invoke a few WebSphere Application Server APIs, which makes the large classpath
unnecessary. In WebSphere Application Server for iSeries V5.1, 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.</p>
<p><strong>Note: </strong>This feature only controls the classpath for compiling your JSP. The environment used to load
and run your JSP remains unchanged.</p>
<p>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.</p>
<p><strong>Name:</strong>
<br>jsp.compile.classpath</p>
<p><strong>Value:</strong>
<br>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.</p>
<p><strong>Configuration</strong>
<br>There are several ways to configure the jsp.compile.classpath feature:</p>
<p>
<ol>
<li><p>To configure the jsp.compile.classpath feature using the WebSphere Development Studio Client for iSeries (recommended), perform the
following steps:</p>
<p>
<ol type="a">
<li>Start the WebSphere Development Studio Client for iSeries.</li>
<li>In the J2EE perspective, expand <strong>Web Modules</strong>, and right click the Web module you want to
modify.</li>
<li>Select <strong>Open With --> Deployment Descriptor Editor</strong>.</li>
<li>In the Web Deployment Descriptor, click the <strong>Extensions</strong> tab.</li>
<li>On the <strong>WebSphere Extensions</strong> page, click <strong>Add</strong> under the <strong>JSP
Attributes</strong> heading.</li>
<li>Set the value of <strong>Name</strong> to <tt>jsp.compile.classpath</tt>.</li>
<li>Set the value of <strong>Value</strong> to the desired classpath. See <a href="#classpath">Determine the classpath to
use</a> for more information on setting the correct classpath.</li>
<li>Click <strong>File --> Save</strong>.</li>
<li>Deploy and start your application.</li>
<li>Verify that the modified classpath is being used. To do this, look at the
/QIBM/UserData/WebASE51/ASE/<em>instance</em>/logs/<em>server</em>/SystemOut.log file. Once you start your
application, a message similar to the following appears in the log:
<pre>JSP Processor in webapp [Default Web Application] Using compile classpath
[/QIBM/ProdData/WebASE51/ASE/lib/webcontainer.jar:/QIBM/ProdData/WebASE51/
ASE/lib/j2ee.jar:/QIBM/UserData/WebASE51/ASE/myInstance/installedApps/server/
DefaultApplication.ear/DefaultWebApplication.war/WEB-INF/classes:]</pre>
<p><strong>Note: </strong>This message is given because the jsp.compile.classpath is set to an empty-string value.</p>
</li>
</ol>
</p>
</li>
<li><p>To configure the jsp.compile.classpath feature on an installed application using a text editor, perform the following
steps:</p>
<p>
<ol type="a">
<li>Use a text editor to open the
/QIBM/UserData/WebASE51/ASE/<em>instance</em>/config/cells/<em>cell-name</em>/applications/<br>
MyEnterpriseApplication.ear/deployments/MyEnterpriseApplication/MyWebApplication.war/<br>
WEB-INF/ibm-web-ext.xmi file (where <em>instance</em> is
the name of your application server instance and <em>cell-name</em> is the name of your cell).</li>
<li>Add the following jspAttribute to the file:
<pre>name=&quot;jsp.compile.classpath&quot; value=&quot;<em>classpath</em>&quot;</pre>
where <em>classpath</em> is the value of the desired classpath. See <a href="#classpath">Determine the classpath to
use</a> for more information on setting the correct classpath. For example, your file should look like the following:
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
.
.
.
&lt;jspAttributes xmi:id=&quot;JSPAttribute_1&quot; name=&quot;jsp.compile.classpath&quot; value=&quot;&quot;/&gt;
&lt;/webappext:WebAppExtension&gt;
</pre>
</li>
<li>Save the updated file.</li>
<li>Copy the updated file to /QIBM/UserData/WebASE51/ASE/installedApps/MyEnterpriseApplication.ear/
<br>MyWebApplication.war/WEB-INF. Replace the old version of the file with the modified version.</li>
<li>Restart your enterprise application in the administrative console.</li>
<li>Verify that the modified classpath is being used. To do this, look at the
/QIBM/UserData/WebASE51/ASE/<em>instance</em>/logs/<em>server</em>/SystemOut.log file. Once you start your
application, a message similar to the following appears in the log:
<pre>JSP Processor in webapp [Default Web Application] Using compile classpath
[/QIBM/ProdData/WebASE51/ASE/lib/webcontainer.jar:/QIBM/ProdData/WebASE51/
ASE/lib/j2ee.jar:/QIBM/UserData/WebASE51/ASE/myInstance/installedApps/server/
DefaultApplication.ear/DefaultWebApplication.war/WEB-INF/classes:]</pre>
<p><strong>Note: </strong>This message is given because the jsp.compile.classpath is set to an empty-string value.</p>
</li>
</ol>
</p>
</li>
</ol>
</p>
<p><a name="classpath"></a><strong>Determine the classpath to use:</strong></p>
<p>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, you must give special consideration to JSPs that use custom tags, because
custom tags contain references to classes.</p>
<p>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:</p>
<p>
<ul>
<li>/QIBM/ProdData/WebASE51/ASE/lib/webcontainer.jar</li>
<li>/QIBM/ProdData/WebASE51/ASE/lib/j2ee.jar</li>
<li><em>your_web_module_directory</em>/WEB-INF/classes</li>
<li>Any .jar or .zip files found in the <em>your_web_module_directory</em>/WEB-INF/lib directory </li>
</ul>
</p>
<p>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.</p>
<p>You can use WebSphere Application Server variables for your classpath entries. For example, if you reference a
WebSphere Application Server .jar file, such as /QIBM/ProdData/WebASE51/ASE/lib/admin.jar, you can use the
WAS_LIBS_DIR variable, which changes your classpath entry to ${WAS_LIBS_DIR}/admin.jar</p>
<p><strong>Example: Determine classpath and configure jsp.compile.classpath</strong></p>
<p>The following JSP references com.ibm.websphere.cache.CacheEntry, com.mycompany.somepackage.MyClass, and
com.mycompany.earlevel.EarClass:</p>
<pre>
&lt;% com.ibm.websphere.cache.CacheEntry entry = null; %&gt;
&lt;% com.mycompany.somepackage.MyClass object = null; %&gt;
&lt;% com.mycompany.earlevel.EarClass object2 = null; %&gt;
</pre>
<p>Three classes are referenced:</p>
<p>
<ul>
<li>CacheEntry.class, which is found in /QIBM/ProdData/WebASE51/ASE/lib/dynacache.jar</li>
<li>MyClass.class, which is assumed to be in
/QIBM/UserData/WebASE51/ASE/default/installedApps/<em>node_name/MyEnterpriseApplication.ear/
<br>MyWebApplication.war/WEB-INF/lib/mywebjar.jar</em> (where <em>node_name</em> is the name of your application
server node, <em>MyEnterpriseApplication.ear</em> is the name of your enterprise application,
<em>MyWebApplication.war</em> is the name of your Web archive file, and <em>mywebjar.jar</em> is the name of your
Java archive file).</li>
<li>EarClass.class, which is assumed to be in
/QIBM/UserData/WebASE51/ASE/default/installedApps/<em>node_name/MyEnterpriseApplication.ear/<br>
myearjar.jar</em> (where <em>node_name</em> is the name of your application server node,
<em>MyEnterpriseApplication.ear</em> is the name of your enterprise application, and <em>myejbjar.jar</em> is the name
of your Java archive file).</li>
</ul>
</p>
<p>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:</p>
<blockquote>
<p><strong>Name:</strong>
<br>jsp.compile.classpath</p>
<p><strong>Value:</strong>
<br>${WAS_LIBS_DIR}/dynacache.jar
${APP_INSTALL_ROOT}/<em>node_name</em>/MyEnterpriseApplication.ear/myearjar.jar (where <em>node_name</em>
is the name of your application server node, <em>MyEnterpriseApplication.ear</em> is the name of your enterprise
application, and <em>myejbjar.jar</em> is the name of your Java archive file).</p>
<p><strong>Note: </strong> The space separator is used between paths (not a colon).</p>
</blockquote>
</body>
</html>