Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame^] | 1 | <html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Apache Tomcat 6.0 (6.0.39) - Jasper 2 JSP Engine How To</title><meta name="author" content="Glenn L. Nielsen"><meta name="author" content="Peter Rossbach"><style type="text/css" media="print">
|
| 2 | .noPrint {display: none;}
|
| 3 | td#mainBody {width: 100%;}
|
| 4 | </style></head><body bgcolor="#ffffff" text="#000000" link="#525D76" alink="#525D76" vlink="#525D76"><table border="0" width="100%" cellspacing="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img src="./images/tomcat.gif" align="right" alt="
|
| 5 | The Apache Tomcat Servlet/JSP Container
|
| 6 | " border="0"></a></td><td><h1><font face="arial,helvetica,sanserif">Apache Tomcat 6.0</font></h1><font face="arial,helvetica,sanserif">Version 6.0.39, Jan 27 2014</font></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img src="./images/asf-logo.gif" align="right" alt="Apache Logo" border="0"></a></td></tr></table><table border="0" width="100%" cellspacing="4"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr noshade="noshade" size="1"></td></tr><tr><!--LEFT SIDE NAVIGATION--><td width="20%" valign="top" nowrap="nowrap" class="noPrint"><p><strong>Links</strong></p><ul><li><a href="index.html">Docs Home</a></li><li><a href="http://wiki.apache.org/tomcat/FAQ">FAQ</a></li></ul><p><strong>User Guide</strong></p><ul><li><a href="introduction.html">1) Introduction</a></li><li><a href="setup.html">2) Setup</a></li><li><a href="appdev/index.html">3) First webapp</a></li><li><a href="deployer-howto.html">4) Deployer</a></li><li><a href="manager-howto.html">5) Manager</a></li><li><a href="realm-howto.html">6) Realms and AAA</a></li><li><a href="security-manager-howto.html">7) Security Manager</a></li><li><a href="jndi-resources-howto.html">8) JNDI Resources</a></li><li><a href="jndi-datasource-examples-howto.html">9) JDBC DataSources</a></li><li><a href="class-loader-howto.html">10) Classloading</a></li><li><a href="jasper-howto.html">11) JSPs</a></li><li><a href="ssl-howto.html">12) SSL</a></li><li><a href="ssi-howto.html">13) SSI</a></li><li><a href="cgi-howto.html">14) CGI</a></li><li><a href="proxy-howto.html">15) Proxy Support</a></li><li><a href="mbeans-descriptor-howto.html">16) MBean Descriptor</a></li><li><a href="default-servlet.html">17) Default Servlet</a></li><li><a href="cluster-howto.html">18) Clustering</a></li><li><a href="balancer-howto.html">19) Load Balancer</a></li><li><a href="connectors.html">20) Connectors</a></li><li><a href="monitoring.html">21) Monitoring and Management</a></li><li><a href="logging.html">22) Logging</a></li><li><a href="apr.html">23) APR/Native</a></li><li><a href="virtual-hosting-howto.html">24) Virtual Hosting</a></li><li><a href="aio.html">25) Advanced IO</a></li><li><a href="extras.html">26) Additional Components</a></li><li><a href="maven-jars.html">27) Mavenized</a></li></ul><p><strong>Reference</strong></p><ul><li><a href="RELEASE-NOTES.txt">Release Notes</a></li><li><a href="config/index.html">Configuration</a></li><li><a href="api/index.html">Javadocs</a></li><li><a href="http://tomcat.apache.org/connectors-doc/">JK 1.2 Documentation</a></li></ul><p><strong>Apache Tomcat Development</strong></p><ul><li><a href="building.html">Building</a></li><li><a href="changelog.html">Changelog</a></li><li><a href="http://wiki.apache.org/tomcat/TomcatVersions">Status</a></li><li><a href="developers.html">Developers</a></li><li><a href="architecture/index.html">Architecture</a></li><li><a href="funcspecs/index.html">Functional Specs.</a></li></ul></td><!--RIGHT SIDE MAIN BODY--><td width="80%" valign="top" align="left" id="mainBody"><h1>Apache Tomcat 6.0</h1><h2>Jasper 2 JSP Engine How To</h2><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Table of Contents"><!--()--></a><a name="Table_of_Contents"><strong>Table of Contents</strong></a></font></td></tr><tr><td><blockquote>
|
| 7 | <ul><li><a href="#Introduction">Introduction</a></li><li><a href="#Configuration">Configuration</a></li><li><a href="#Known_issues">Known issues</a></li><li><a href="#Production_Configuration">Production Configuration</a></li><li><a href="#Web_Application_Compilation">Web Application Compilation</a></li><li><a href="#Using_Jikes">Using Jikes</a></li></ul>
|
| 8 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Introduction"><strong>Introduction</strong></a></font></td></tr><tr><td><blockquote>
|
| 9 |
|
| 10 | <p>Tomcat 6.0 uses the Jasper 2 JSP Engine to implement
|
| 11 | the <a href="http://wiki.apache.org/tomcat/Specifications">JavaServer Pages 2.1</a>
|
| 12 | specification.</p>
|
| 13 |
|
| 14 | <p>Jasper 2 has been redesigned to significantly improve performance over
|
| 15 | the original Jasper. In addition to general code improvements the following
|
| 16 | changes were made:
|
| 17 | <ul>
|
| 18 | <li><strong>JSP Custom Tag Pooling</strong> - The java objects instantiated
|
| 19 | for JSP Custom Tags can now be pooled and reused. This significantly boosts
|
| 20 | the performance of JSP pages which use custom tags.</li>
|
| 21 | <li><strong>Background JSP compilation</strong> - If you make a change to
|
| 22 | a JSP page which had already been compiled Jasper 2 can recompile that
|
| 23 | page in the background. The previously compiled JSP page will still be
|
| 24 | available to serve requests. Once the new page has been compiled
|
| 25 | successfully it will replace the old page. This helps improve availability
|
| 26 | of your JSP pages on a production server.</li>
|
| 27 | <li><strong>Recompile JSP when included page changes</strong> - Jasper 2
|
| 28 | can now detect when a page included at compile time from a JSP has changed
|
| 29 | and then recompile the parent JSP.</li>
|
| 30 | <li><strong>JDT used to compile JSP pages</strong> - The
|
| 31 | Eclipse JDT Java compiler is now used to perform JSP java source code
|
| 32 | compilation. This compiler loads source dependencies from the container
|
| 33 | classloader. Ant and javac can still be used.</li>
|
| 34 | </ul>
|
| 35 | </p>
|
| 36 |
|
| 37 | <p>Jasper is implemented using the servlet class
|
| 38 | <code>org.apache.jasper.servlet.JspServlet</code>.</p>
|
| 39 |
|
| 40 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Configuration"><strong>Configuration</strong></a></font></td></tr><tr><td><blockquote>
|
| 41 |
|
| 42 | <p>By default Jasper is configured for use when doing web application
|
| 43 | development. See the section <a href="#Production Configuration">
|
| 44 | Production Configuration</a> for information on configuring Jasper
|
| 45 | for use on a production Tomcat server.</p>
|
| 46 |
|
| 47 | <p>The servlet which implements Jasper is configured using init parameters
|
| 48 | in your global <code>$CATALINA_BASE/conf/web.xml</code>.
|
| 49 |
|
| 50 | <ul>
|
| 51 | <li><strong>checkInterval</strong> - If development is false and checkInterval
|
| 52 | is greater than zero, background compiles are enabled. checkInterval is the time
|
| 53 | in seconds between checks to see if a JSP page (and its dependent files) needs
|
| 54 | to be recompiled. Default <code>0</code> seconds.</li>
|
| 55 |
|
| 56 | <li><strong>classdebuginfo</strong> - Should the class file be compiled with
|
| 57 | debugging information? <code>true</code> or <code>false</code>, default
|
| 58 | <code>true</code>.
|
| 59 | </li>
|
| 60 |
|
| 61 | <li><strong>classpath</strong> - Defines the class path to be used to compile
|
| 62 | the generated servlets. This parameter only has an effect if the ServletContext
|
| 63 | attribute org.apache.jasper.Constants.SERVLET_CLASSPATH is not set. This
|
| 64 | attribute is always set when Jasper is used within Tomcat. By default the
|
| 65 | classpath is created dynamically based on the current web application.</li>
|
| 66 |
|
| 67 | <li><strong>compiler</strong> - Which compiler Ant should use to compile JSP
|
| 68 | pages. See the Ant documentation for more information. If the value is not set,
|
| 69 | then the default Eclipse JDT Java compiler will be used instead of using Ant.
|
| 70 | No default value.</li>
|
| 71 |
|
| 72 | <li><strong>compilerSourceVM</strong> - What JDK version are the source files
|
| 73 | compatible with? (Default value: <code>1.5</code>)</li>
|
| 74 |
|
| 75 | <li><strong>compilerTargetVM</strong> - What JDK version are the generated files
|
| 76 | compatible with? (Default value: <code>1.5</code>)</li>
|
| 77 |
|
| 78 | <li><strong>development</strong> - Is Jasper used in development mode? If true,
|
| 79 | the frequency at which JSPs are checked for modification may be specified via
|
| 80 | the modificationTestInterval parameter.<code>true</code> or <code>false</code>,
|
| 81 | default <code>true</code>.</li>
|
| 82 |
|
| 83 | <li><strong>displaySourceFragment</strong> - Should a source fragment be
|
| 84 | included in exception messages? <code>true</code> or <code>false</code>,
|
| 85 | default <code>true</code>.</li>
|
| 86 |
|
| 87 | <li><strong>dumpSmap</strong> - Should the SMAP info for JSR45 debugging be
|
| 88 | dumped to a file? <code>true</code> or <code>false</code>, default
|
| 89 | <code>false</code>. <code>false</code> if suppressSmap is true.</li>
|
| 90 |
|
| 91 | <li><strong>enablePooling</strong> - Determines whether tag handler pooling is
|
| 92 | enabled. This is a compilation option. It will not alter the behaviour of JSPs
|
| 93 | that have already been compiled. <code>true</code> or <code>false</code>,
|
| 94 | default <code>true</code>.
|
| 95 | </li>
|
| 96 |
|
| 97 | <li><strong>engineOptionsClass</strong> - Allows specifying the Options class
|
| 98 | used to configure Jasper. If not present, the default EmbeddedServletOptions
|
| 99 | will be used.
|
| 100 | </li>
|
| 101 |
|
| 102 | <li><strong>errorOnUseBeanInvalidClassAttribute</strong> - Should Jasper issue
|
| 103 | an error when the value of the class attribute in an useBean action is not a
|
| 104 | valid bean class? <code>true</code> or <code>false</code>, default
|
| 105 | <code>true</code>.</li>
|
| 106 |
|
| 107 | <li><strong>fork</strong> - Have Ant fork JSP page compiles so they are
|
| 108 | performed in a separate JVM from Tomcat? <code>true</code> or
|
| 109 | <code>false</code>, default <code>true</code>.</li>
|
| 110 |
|
| 111 | <li><strong>genStringAsCharArray</strong> - Should text strings be generated as
|
| 112 | char arrays, to improve performance in some cases? Default
|
| 113 | <code>false</code>. The alternative name of <strong>genStrAsCharArray</strong>
|
| 114 | for this initialisation parameter is also supported.</li>
|
| 115 |
|
| 116 | <li><strong>ieClassId</strong> - The class-id value to be sent to Internet
|
| 117 | Explorer when using <jsp:plugin> tags. Default
|
| 118 | <code>clsid:8AD9C840-044E-11D1-B3E9-00805F499D93</code>.</li>
|
| 119 |
|
| 120 | <li><strong>javaEncoding</strong> - Java file encoding to use for generating
|
| 121 | java source files. Default <code>UTF8</code>.</li>
|
| 122 |
|
| 123 | <li><strong>keepgenerated</strong> - Should we keep the generated Java source
|
| 124 | code for each page instead of deleting it? <code>true</code> or
|
| 125 | <code>false</code>, default <code>true</code>.</li>
|
| 126 |
|
| 127 | <li><strong>mappedfile</strong> - Should we generate static content with one
|
| 128 | print statement per input line, to ease debugging?
|
| 129 | <code>true</code> or <code>false</code>, default <code>true</code>.</li>
|
| 130 |
|
| 131 | <li><strong>modificationTestInterval</strong> - Causes a JSP (and its dependent
|
| 132 | files) to not be checked for modification during the specified time interval
|
| 133 | (in seconds) from the last time the JSP was checked for modification. A value of
|
| 134 | 0 will cause the JSP to be checked on every access. Used in development mode
|
| 135 | only. Default is <code>4</code> seconds.</li>
|
| 136 |
|
| 137 | <li><strong>recompileOnFail</strong> - If a JSP compilation fails should the
|
| 138 | modificationTestInterval be ignored and the next access trigger a re-compilation
|
| 139 | attempt? Used in development mode only and is disabled by default as compilation
|
| 140 | may be expensive and could lead to excessive resource usage.</li>
|
| 141 |
|
| 142 | <li><strong>scratchdir</strong> - What scratch directory should we use when
|
| 143 | compiling JSP pages? Default is the work directory for the current web
|
| 144 | application.</li>
|
| 145 |
|
| 146 | <li><strong>suppressSmap</strong> - Should the generation of SMAP info for JSR45
|
| 147 | debugging be suppressed? <code>true</code> or <code>false</code>, default
|
| 148 | <code>false</code>.</li>
|
| 149 |
|
| 150 | <li><strong>trimSpaces</strong> - Should white spaces in template text between
|
| 151 | actions or directives be trimmed ?, default <code>false</code>.</li>
|
| 152 |
|
| 153 | <li><strong>xpoweredBy</strong> - Determines whether X-Powered-By response
|
| 154 | header is added by generated servlet. <code>true</code> or <code>false</code>,
|
| 155 | default <code>false</code>.</li>
|
| 156 | </ul>
|
| 157 | </p>
|
| 158 |
|
| 159 | <p>The Java compiler from Eclipse JDT in included as the default compiler. It is
|
| 160 | an advanced Java compiler which will load all dependencies from the Tomcat class
|
| 161 | loader, which will help tremendously when compiling on large installations with
|
| 162 | tens of JARs. On fast servers, this will allow sub-second recompilation cycles
|
| 163 | for even large JSP pages.</p>
|
| 164 |
|
| 165 | <p>Apache Ant, which was used in previous Tomcat releases, can be used instead
|
| 166 | of the new compiler by simply removing the <code>lib/ecj-*.jar</code> file,
|
| 167 | and placing the <code>ant.jar</code> and <code>ant-launcher.jar</code> files
|
| 168 | from the latest Ant distribution in the <code>lib</code> folder.</p>
|
| 169 |
|
| 170 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Known issues"><!--()--></a><a name="Known_issues"><strong>Known issues</strong></a></font></td></tr><tr><td><blockquote>
|
| 171 |
|
| 172 | <p>As described in
|
| 173 | <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=39089">
|
| 174 | bug 39089</a>, a known JVM issue,
|
| 175 | <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6294277">
|
| 176 | bug 6294277</a>, may cause a
|
| 177 | <code>java.lang.InternalError: name is too long to represent</code> exception
|
| 178 | when compiling very large JSPs. If this is observed then it may be worked around
|
| 179 | by using one of the following:
|
| 180 | <ul>
|
| 181 | <li>reduce the size of the JSP</li>
|
| 182 | <li>disable SMAP generation and JSR-045 support by setting
|
| 183 | <code>suppressSmap</code> to <code>true</code>.</li>
|
| 184 | </ul>
|
| 185 | </p>
|
| 186 |
|
| 187 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Production Configuration"><!--()--></a><a name="Production_Configuration"><strong>Production Configuration</strong></a></font></td></tr><tr><td><blockquote>
|
| 188 |
|
| 189 | <p>The main JSP optimization which can be done is precompilation of JSPs.
|
| 190 | However, this might not be possible (for example, when using the
|
| 191 | jsp-property-group feature) or practical, in which case the configuration of the
|
| 192 | Jasper servlet becomes critical.</p>
|
| 193 |
|
| 194 | <p>When using Jasper 2 in a production Tomcat server you should consider making
|
| 195 | the following changes from the default configuration.
|
| 196 | <ul>
|
| 197 | <li><strong>development</strong> - To disable on access checks for JSP
|
| 198 | pages compilation set this to <code>false</code>.</li>
|
| 199 | <li><strong>genStringAsCharArray</strong> - To generate slightly more efficient
|
| 200 | char arrays, set this to <code>true</code>.</li>
|
| 201 | <li><strong>modificationTestInterval</strong> - If development has to be set to
|
| 202 | <code>true</code> for any reason (such as dynamic generation of JSPs), setting
|
| 203 | this to a high value will improve performance a lot.</li>
|
| 204 | <li><strong>trimSpaces</strong> - To remove useless bytes from the response,
|
| 205 | set this to <code>true</code>.</li>
|
| 206 | </ul>
|
| 207 | </p>
|
| 208 |
|
| 209 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Web Application Compilation"><!--()--></a><a name="Web_Application_Compilation"><strong>Web Application Compilation</strong></a></font></td></tr><tr><td><blockquote>
|
| 210 |
|
| 211 | <p>Using Ant is the preferred way to compile web applications using JSPC. Note
|
| 212 | that when pre-compiling JSPs, SMAP information only be included in the final
|
| 213 | classes if suppressSmap is false and compile is true.
|
| 214 | Use the script given below (a similar script is included in the "deployer"
|
| 215 | download) to precompile a webapp:
|
| 216 | </p>
|
| 217 |
|
| 218 | <p>
|
| 219 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 220 | <project name="Webapp Precompilation" default="all" basedir=".">
|
| 221 |
|
| 222 | <import file="${tomcat.home}/bin/catalina-tasks.xml"/>
|
| 223 |
|
| 224 | <target name="jspc">
|
| 225 |
|
| 226 | <jasper
|
| 227 | validateXml="false"
|
| 228 | uriroot="${webapp.path}"
|
| 229 | webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
|
| 230 | outputDir="${webapp.path}/WEB-INF/src" />
|
| 231 |
|
| 232 | </target>
|
| 233 |
|
| 234 | <target name="compile">
|
| 235 |
|
| 236 | <mkdir dir="${webapp.path}/WEB-INF/classes"/>
|
| 237 | <mkdir dir="${webapp.path}/WEB-INF/lib"/>
|
| 238 |
|
| 239 | <javac destdir="${webapp.path}/WEB-INF/classes"
|
| 240 | optimize="off"
|
| 241 | debug="on" failonerror="false"
|
| 242 | srcdir="${webapp.path}/WEB-INF/src"
|
| 243 | excludes="**/*.smap">
|
| 244 | <classpath>
|
| 245 | <pathelement location="${webapp.path}/WEB-INF/classes"/>
|
| 246 | <fileset dir="${webapp.path}/WEB-INF/lib">
|
| 247 | <include name="*.jar"/>
|
| 248 | </fileset>
|
| 249 | <pathelement location="${tomcat.home}/lib"/>
|
| 250 | <fileset dir="${tomcat.home}/lib">
|
| 251 | <include name="*.jar"/>
|
| 252 | </fileset>
|
| 253 | <fileset dir="${tomcat.home}/bin">
|
| 254 | <include name="*.jar"/>
|
| 255 | </fileset>
|
| 256 | </classpath>
|
| 257 | <include name="**" />
|
| 258 | <exclude name="tags/**" />
|
| 259 | </javac>
|
| 260 |
|
| 261 | </target>
|
| 262 |
|
| 263 | <target name="all" depends="jspc,compile">
|
| 264 | </target>
|
| 265 |
|
| 266 | <target name="cleanup">
|
| 267 | <delete>
|
| 268 | <fileset dir="${webapp.path}/WEB-INF/src"/>
|
| 269 | <fileset dir="${webapp.path}/WEB-INF/classes/org/apache/jsp"/>
|
| 270 | </delete>
|
| 271 | </target>
|
| 272 |
|
| 273 | </project>
|
| 274 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 275 | </p>
|
| 276 |
|
| 277 | <p>
|
| 278 | The following command line can be used to run the script
|
| 279 | (replacing the tokens with the Tomcat base path and the path to the webapp
|
| 280 | which should be precompiled):<br>
|
| 281 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 282 | $ANT_HOME/bin/ant -Dtomcat.home=<$TOMCAT_HOME> -Dwebapp.path=<$WEBAPP_PATH>
|
| 283 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 284 | </p>
|
| 285 |
|
| 286 | <p>
|
| 287 | Then, the declarations and mappings for the servlets which were generated
|
| 288 | during the precompilation must be added to the web application deployment
|
| 289 | descriptor. Insert the <code>${webapp.path}/WEB-INF/generated_web.xml</code>
|
| 290 | at the right place inside the <code>${webapp.path}/WEB-INF/web.xml</code> file.
|
| 291 | Restart the web application (using the manager) and test it to verify it is
|
| 292 | running fine with precompiled servlets. An appropriate token placed in the
|
| 293 | web application deployment descriptor may also be used to automatically
|
| 294 | insert the generated servlet declarations and mappings using Ant filtering
|
| 295 | capabilities. This is actually how all the webapps distributed with Tomcat
|
| 296 | are automatically compiled as part of the build process.
|
| 297 | </p>
|
| 298 |
|
| 299 | <p>
|
| 300 | At the jasper task you can use the option <code>addWebXmlMappings</code> for
|
| 301 | automatic merge the <code>${webapp.path}/WEB-INF/generated_web.xml</code>
|
| 302 | with the current web application deployment descriptor at
|
| 303 | <code>${webapp.path}/WEB-INF/web.xml</code>. When you want to use Java 5
|
| 304 | features inside your jsp's, add the following javac compiler task attributes:
|
| 305 | <code>source="1.5" target="1.5"</code>. For live
|
| 306 | applications you can also compile with <code>optimize="on"</code> and
|
| 307 | without debug info <code>debug="off"</code>.
|
| 308 | </p>
|
| 309 |
|
| 310 | <p>
|
| 311 | When you don't want to stop the jsp generation at first jsp syntax error, use
|
| 312 | <code>failOnError="false"</code>and with
|
| 313 | <code>showSuccess="true"</code> all successfull <i>jsp to java</i>
|
| 314 | generation are printed out. Sometimes it is very helpfull, when you cleanup the
|
| 315 | generate java source files at <code>${webapp.path}/WEB-INF/src</code>
|
| 316 | and the compile jsp servlet classes at
|
| 317 | <code>${webapp.path}/WEB-INF/classes/org/apache/jsp</code>.
|
| 318 | </p>
|
| 319 |
|
| 320 | <p><strong>Hints:</strong>
|
| 321 | <ul>
|
| 322 | <li> When you switch to another Tomcat release, then regenerate and recompile
|
| 323 | your jsp's with the new Tomcat version.</li>
|
| 324 | <li>Use java system property at server runtime to disable PageContext pooling
|
| 325 | <code>org.apache.jasper.runtime.JspFactoryImpl.USE_POOL=false</code>.
|
| 326 | and limit the buffering with
|
| 327 | <code>org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true</code>. Note
|
| 328 | that changing from the defaults may affect performance, but it will vary
|
| 329 | depending on the application.</li>
|
| 330 | </ul>
|
| 331 | </p>
|
| 332 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Using Jikes"><!--()--></a><a name="Using_Jikes"><strong>Using Jikes</strong></a></font></td></tr><tr><td><blockquote>
|
| 333 |
|
| 334 | <p>If you wish to use
|
| 335 | <a href="http://oss.software.ibm.com/developerworks/opensource/jikes/">
|
| 336 | Jikes</a> to compile JSP pages:
|
| 337 | <ul>
|
| 338 | <li>From your <a href="http://ant.apache.org">Ant</a> installation, copy ant.jar
|
| 339 | and (if it's available: Ant 1.5 and later) ant-launcher.jar to
|
| 340 | <code>$CATALINA_HOME/lib</code>.</li>
|
| 341 | <li>Download and install jikes. jikes must support the -encoding option.
|
| 342 | Execute <code>jikes -help</code> to verify that it was built with support
|
| 343 | for <code>-encoding</code>.</li>
|
| 344 | <li>Set the init parameter <code>compiler</code> to <code>jikes</code>.</li>
|
| 345 | <li>Define the property <code>-Dbuild.compiler.emacs=true</code> when starting
|
| 346 | Tomcat by adding it to your <code>CATALINA_OPTS</code> environment variable.
|
| 347 | This changes how jikes outputs error messages so that it is compatible with
|
| 348 | Jasper.</li>
|
| 349 | <li>If you get an error reporting that jikes can't use UTF8 encoding, try
|
| 350 | setting the init parameter <code>javaEncoding</code> to
|
| 351 | <code>ISO-8859-1</code>.</li>
|
| 352 | </ul>
|
| 353 | </p>
|
| 354 |
|
| 355 | </blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr noshade="noshade" size="1"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font color="#525D76" size="-1"><em>
|
| 356 | Copyright © 1999-2014, Apache Software Foundation
|
| 357 | </em></font></div></td></tr></table></body></html> |