| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>Chapter 8. Configuring JSP Support</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"><meta name="keywords" content="jetty, servlet, servlet-api, cometd, http, websocket, eclipse, maven, java, server, software"><link rel="home" href="index.html" title="Jetty : The Definitive Reference"><link rel="up" href="configuring.html" title="Part II. Jetty Configuration"><link rel="prev" href="spnego-support.html" title="Spnego Support"><link rel="next" href="administration.html" title="Part III. Jetty Administration Guide"><link xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" rel="shortcut icon" href="images/favicon.ico"><script type="text/javascript" src="js/shCore.js"></script><script type="text/javascript" src="js/shBrushJava.js"></script><script type="text/javascript" src="js/shBrushXml.js"></script><script type="text/javascript" src="js/shBrushBash.js"></script><script type="text/javascript" src="js/shBrushJScript.js"></script><script type="text/javascript" src="js/shBrushSql.js"></script><script type="text/javascript" src="js/shBrushProperties.js"></script><script type="text/javascript" src="js/shBrushPlain.js"></script><link type="text/css" rel="stylesheet" href="css/shCore.css"><link type="text/css" rel="stylesheet" href="css/shThemeEclipse.css"><link type="text/css" rel="stylesheet" href="css/font-awesome.min.css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><tr><td style="width: 25%"><a href="http://www.eclipse.org/jetty"><img src="images/jetty-header-logo.png" alt="Jetty Logo"></a><br><span style="font-size: small"> |
| Version: 9.3.0.v20150612</span></td><td style="width: 50%"><script type="text/javascript"> (function() { |
| var cx = '016459005284625897022:obd4lsai2ds'; |
| var gcse = document.createElement('script'); |
| gcse.type = 'text/javascript'; |
| gcse.async = true; |
| gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + |
| '//www.google.com/cse/cse.js?cx=' + cx; |
| var s = document.getElementsByTagName('script')[0]; |
| s.parentNode.insertBefore(gcse, s); |
| })(); |
| </script><gcse:search></gcse:search></td></tr></table><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 8. Configuring JSP Support</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="spnego-support.html"><i class="icon-chevron-left"></i> Previous</a> </td><th width="60%" align="center">Part II. Jetty Configuration<br><a accesskey="p" href="index.html"><i class="icon-home"></i> Home</a></th><td width="20%" align="right"> <a accesskey="n" href="administration.html">Next <i class="icon-chevron-right"></i></a></td></tr></table><hr></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="jetty-callout"><h5 class="callout"><a href="http://www.webtide.com/">Contact the core Jetty developers at |
| <span class="website">www.webtide.com</span></a></h5><p> |
| private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... |
| scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery |
| </p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="configuring-jsp"></a>Chapter 8. Configuring JSP Support</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="configuring-jsp.html#jsp-support">Configuring JSP</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="jsp-support"></a>Configuring JSP</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="configuring-jsp.html#which-jsp-implementation">Which JSP Implementation</a></span></dt><dt><span class="section"><a href="configuring-jsp.html#d0e6586">Precompiling JSPs</a></span></dt><dt><span class="section"><a href="configuring-jsp.html#compiling-jsps">Runtime Compiling JSPs</a></span></dt><dt><span class="section"><a href="configuring-jsp.html#modifying-configuration">Modifying Configuration</a></span></dt><dt><span class="section"><a href="configuring-jsp.html#using-jstl-taglibs-for-jetty7-jetty8">Using JSTL Taglibs</a></span></dt><dt><span class="section"><a href="configuring-jsp.html#using-jsf-taglibs">Using JSF Taglibs</a></span></dt></dl></div><p>This document provides information about configuring Java Server Pages |
| for Jetty.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="which-jsp-implementation"></a>Which JSP Implementation</h3></div></div></div><p>From jetty-9.2 onwards, we are using Jasper from <a class="link" href="http://tomcat.apache.org/tomcat-8.0-doc/jasper-howto.html" target="_top">Apache</a> |
| as the default JSP container implementation. In previous versions we used |
| Jasper from <a class="link" href="http://jsp.java.net" target="_top">Glassfish</a>, and if |
| you wish to, you can continue to do so.</p><p>The jetty-distribution by default enables the jsp <a class="link" href="startup-modules.html" title="Managing Startup Modules">module</a>, and by default, this <a class="link" href="startup-modules.html" title="Managing Startup Modules">module</a> is set to Apache Jasper. To change |
| to use Glassfish Jasper instead, edit the |
| <code class="filename">$JETTY_HOME/start.d/jsp.mod</code> file and change the line |
| indicated:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: plain;toolbar: false"> |
| <![CDATA[# |
| # Jetty JSP Module |
| # |
| |
| [depend] |
| servlet |
| annotations |
| apache-jsp |
| |
| ]]> |
| </script></div><p>Note that the availability of some JSP features may depend on which |
| JSP container implementation you are using. Note also that it may not be |
| possible to precompile your jsps with one container and deploy to the |
| other.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e6559"></a>JSPs and Embedding</h4></div></div></div><p>If you have an embedded setup for your webapp and wish to use |
| jsps, you will need to ensure that a JSP engine is correctly |
| initialized.</p><p>For both Apache and Glassfish JSP engines, a Servlet Specification |
| 3.1 style <a class="link" href="using-annotations.html#servlet-container-initializers" title="ServletContainerInitializers">ServletContainerInitializer</a> |
| is used to accomplish this. You will need to ensure that this |
| ServletContainerInitializer is run by jetty. Perhaps the easiest way to |
| do this is to enable annotations processing so that jetty automatically |
| discovers and runs it. The <a class="link" href="embedded-examples.html" title="Embedded Examples">Embedded |
| Examples</a> section includes a <a class="link" href="embedded-examples.html#embedded-webapp-jsp" title="Web Application with JSP">worked code example</a> of how to do |
| this.</p><p>Alternatively, you can manually wire in the appropriate |
| ServletContainerInitializer as shown in the <a class="link" href="https://github.com/jetty-project/embedded-jetty-jsp/blob/master/src/main/java/org/eclipse/jetty/demo/Main.java" target="_top">embedded-jetty-jsp</a> |
| example on <a class="link" href="https://github.com/jetty-project" target="_top">github</a>, in which case |
| you will not need the jetty-annotations jar on your classpath, nor |
| include the AnnotationConfiguration in the list of <a class="link" href="configuring-webapps.html#webapp-configurations" title="Configuration Classes">configuration classes</a>.</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d0e6586"></a>Precompiling JSPs</h3></div></div></div><p>You can either follow the instructions on precompilation provided by |
| the JSP container of your choice (either <a class="link" href="http://jsp.java.net" target="_top">Glassfish</a> or <a class="link" href="http://tomcat.apache.org/tomcat-8.0-doc/jasper-howto.html" target="_top">Apache</a>), |
| or if you are using maven for your builds, you can use the <a class="link" href="jetty-jspc-maven-plugin.html" title="Jetty Jspc Maven Plugin">jetty-jspc-maven</a> plugin to do it |
| for you.</p><p>If you have precompiled your jsps, and have customized the output |
| package prefix (which is <code class="literal">org.apache.jsp</code> by default), |
| you should configure your webapp context to tell Jetty about this custom |
| package name. You can do this using a servlet context init-param called |
| <code class="literal">org.eclipse.jetty.servlet.jspPackagePrefix</code>.</p><p>For example, suppose you have precompiled your jsps with the custom |
| package prefix of <code class="literal">com.acme</code>, then you would add the |
| following lines to your web.xml file:</p><div class="informalexample"><p><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ <context-param> |
| <param-name>org.eclipse.jetty.servlet.jspPackagePrefix</param-name> |
| <param-value>com.acme</param-value> |
| </context-param> |
| ]]> |
| </script></p></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><i class="icon-asterisk"></i> Note</h3><p>both jetty maven plugins - <a class="link" href="jetty-jspc-maven-plugin.html" title="Jetty Jspc Maven Plugin">jetty-jspc-maven-plugin</a> and the |
| <a class="link" href="jetty-maven-plugin.html" title="Configuring the Jetty Maven Plugin">jetty-maven-plugin</a> - will only |
| use Apache Jasper</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="compiling-jsps"></a>Runtime Compiling JSPs</h3></div></div></div><p>Depending on which JSP container you elect to use, the configuration |
| and compilation characteristics will be different.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e6632"></a>Apache JSP Container</h4></div></div></div><p>By default, the Apache JSP container will look for the Eclipse |
| Java Compiler (jdt). The jetty distribution ships a copy of this in |
| $JETTY_HOME/lib/apache-jsp. If you wish to use a different compiler, you |
| will need to configure the <code class="literal">compilerClassName</code> |
| init-param on the <code class="literal">JspServlet</code> with the name of the |
| class.</p><div class="table"><a name="d0e6643"></a><p class="title"><b>Table 8.1. Understanding Apache JspServlet Parameters</b></p><div class="table-contents"><table summary="Understanding Apache JspServlet Parameters" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th align="left">init param</th><th align="left">Description</th><th align="left">Default</th><th align="left"><code class="filename">webdefault.xml</code></th></tr></thead><tbody><tr><td>classpath</td><td><code class="code">Classpath used for jsp compilation. Only used if |
| org.apache.catalina.jsp_classpath context attribute is not |
| set, which it is in Jetty.</code></td><td>-</td><td>–</td></tr><tr><td>classdebuginfo</td><td>Include debugging info in class file.</td><td>TRUE</td><td>–</td></tr><tr><td>checkInterval</td><td>Interval in seconds between background recompile |
| checks. Only relevant if <code class="code"> |
| development=false</code>.</td><td>0</td><td>–</td></tr><tr><td>development</td><td><code class="code">development=true</code>, recompilation checks |
| occur on each request. See also <code class="code"> |
| modificationTestInterval</code>.</td><td>TRUE</td><td>–</td></tr><tr><td>displaySourceFragment</td><td>Should a source fragment be included in exception |
| messages</td><td>TRUE</td><td>–</td></tr><tr><td>errorOnUseBeanInvalidClassAttribute</td><td>Should Jasper issue an error when the value of the |
| class attribute in an useBean action is not a valid bean |
| class</td><td>TRUE</td><td>–</td></tr><tr><td>fork</td><td>Should Ant fork its Java compiles of JSP pages?</td><td>TRUE</td><td>FALSE</td></tr><tr><td>keepgenerated</td><td>Do you want to keep the generated Java files |
| around?</td><td>TRUE</td><td>–</td></tr><tr><td>trimSpaces</td><td>Should white spaces between directives or actions be |
| trimmed?</td><td>FALSE</td><td>–</td></tr><tr><td>enablePooling</td><td>Determines whether tag handler pooling is |
| enabled.</td><td>TRUE</td><td>–</td></tr><tr><td>engineOptionsClass</td><td>Allows specifying the Options class used to configure |
| Jasper. If not present, the default EmbeddedServletOptions |
| will be used.</td><td>–</td><td class="auto-generated"> </td></tr><tr><td>mappedFile</td><td>Support for mapped Files. Generates a servlet that has |
| a print statement per line of the JSP file </td><td>TRUE</td><td>–</td></tr><tr><td>suppressSmap</td><td>Generation of SMAP info for JSR45 debugging.</td><td>FALSE</td><td>–</td></tr><tr><td>dumpSmap</td><td>Dump SMAP JSR45 info to a file.</td><td>FALSE</td><td>–</td></tr><tr><td>genStrAsCharArray</td><td>Option for generating Strings.</td><td>FALSE</td><td>–</td></tr><tr><td>ieClassId</td><td>The class-id value to be sent to Internet Explorer when |
| using <jsp:plugin> tags.</td><td>clsid:8AD9C840-044E-11D1-B3E9-00805F499D93</td><td>–</td></tr><tr><td>maxLoadedJsps</td><td>The maximum number of JSPs that will be loaded for a |
| web application. If more than this number of JSPs are loaded, |
| the least recently used JSPs will be unloaded so that the |
| number of JSPs loaded at any one time does not exceed this |
| limit. A value of zero or less indicates no limit.</td><td>-1</td><td>–</td></tr><tr><td>jspIdleTimeout</td><td>The amount of time in seconds a JSP can be idle before |
| it is unloaded. A value of zero or less indicates never |
| unload.</td><td>-1</td><td>–</td></tr><tr><td>scratchDir</td><td>Directory where servlets are generated. See</td><td>–</td><td>–</td></tr><tr><td>compilerClassName</td><td>If not set, defaults to the Eclipse jdt |
| compiler.</td><td>–</td><td class="auto-generated"> </td></tr><tr><td>compiler</td><td>Used if the Eclipse jdt compiler cannot be found on the |
| classpath. It is the classname of a compiler that Ant should |
| invoke.</td><td>–</td><td>–</td></tr><tr><td>compilerTargetVM</td><td>Target vm to compile for.</td><td>1.7</td><td>–</td></tr><tr><td>compilerSourceVM</td><td>Sets source compliance level for the jdt |
| compiler.</td><td>1.7</td><td>–</td></tr><tr><td>javaEncoding</td><td>Pass through the encoding to use for the |
| compilation.</td><td>UTF8</td><td>–</td></tr><tr><td>modificationTestInterval</td><td>If <code class="code">development=true</code>, interval between |
| recompilation checks, triggered by a request.</td><td>4</td><td>–</td></tr><tr><td>xpoweredBy</td><td>Generate an X-Powered-By response header.</td><td>FALSE</td><td>FALSE</td></tr><tr><td>recompileOnFail</td><td>If a JSP compilation fails should the |
| modificationTestInterval be ignored and the next access |
| trigger a re-compilation attempt? Used in development mode |
| only and is disabled by default as compilation may be |
| expensive and could lead to excessive resource usage.</td><td>-</td><td>–</td></tr></tbody></table></div></div><p><br class="table-break"></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e6910"></a>Glassfish JSP Container</h4></div></div></div><div class="section"><div class="titlepage"></div><p>To compile <code class="filename">.jsp</code> files into Java classes, |
| you need a Java compiler. You can acquire a Java compiler from the JVM |
| if you are using a full JDK, or from a third party Jar.</p><p>By default, the Glassfish JSP container tries to use the |
| compiler that is part of the JDK. <span class="bold"><strong>NOTE:</strong></span> when using the JDK compiler, the system |
| does <span class="emphasis"><em>not</em></span> save your class files to disk unless you |
| use the <code class="code">saveBytecode</code> init-param as described |
| below.</p><p>If you do not have a full JDK, you can configure the Eclipse |
| Java Compiler that Jetty ships in the distro in |
| <code class="filename">$JETTY_HOME/lib/jsp/.</code>You need to define a |
| SystemProperty that prevents the Glassfish JSP engine from defaulting |
| to the in-JVM compiler.</p><p>This is best done when using the standalone distro by |
| uncommenting the System property |
| <code class="literal">org.apache.jasper.compiler.disablejsr199</code> in the jsp |
| <a class="link" href="startup-modules.html" title="Managing Startup Modules">module</a>:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: plain;toolbar: false"> |
| <![CDATA[ |
| |
| -Dorg.apache.jasper.compiler.disablejsr199=true |
| |
| ]]> |
| </script></div><p>Or for embedded usages, simply define this as a normal System |
| property.</p></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="configuring-jsp-for-jetty"></a>Configuration</h4></div></div></div><p>The JSP engine has many configuration parameters. Some parameters |
| affect only precompilation, and some affect runtime recompilation |
| checking. Parameters also differ among the various versions of the JSP |
| engine. This page lists the configuration parameters, their meanings, |
| and their default settings. Set all parameters on the |
| <code class="code">org.apache.jasper.JspServlet</code> instance defined in the <a class="link" href="webdefault-xml.html" title="webdefault.xml"><code class="filename">webdefault.xml</code></a> |
| file.</p><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><i class="icon-asterisk"></i> Note</h3><p>Be careful: for all of these parameters, if the value you set |
| doesn't take effect, try using all lower case instead of camel case, |
| or capitalizing only some of the words in the name, as JSP is |
| inconsistent in its parameter naming strategy.</p></div><div class="table"><a name="d0e6963"></a><p class="title"><b>Table 8.2. Understanding Glassfish JSP Parameters</b></p><div class="table-contents"><table summary="Understanding Glassfish JSP Parameters" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th align="left">init param</th><th align="left">Description</th><th align="left">Default</th><th align="left"><code class="filename">webdefault.xml</code></th></tr></thead><tbody><tr><td>development</td><td><code class="code">development=true</code>, recompilation checks occur |
| on each request. See also <code class="code"> |
| modificationTestInterval</code>.</td><td>TRUE</td><td>–</td></tr><tr><td>fork</td><td>Should Ant fork its Java compiles of JSP pages?</td><td>TRUE</td><td>FALSE</td></tr><tr><td>keepgenerated</td><td>Do you want to keep the generated Java files |
| around?</td><td>FALSE</td><td>–</td></tr><tr><td>saveBytecode</td><td>If class files are generated as byte arrays, should they |
| be saved to disk at the end of compilations?</td><td>FALSE</td><td>–</td></tr><tr><td>trimSpaces</td><td>Should white spaces between directives or actions be |
| trimmed?</td><td>FALSE</td><td>–</td></tr><tr><td>enablePooling</td><td>Determines whether tag handler pooling is |
| enabled.</td><td>TRUE</td><td>–</td></tr><tr><td>mappedFile</td><td>Support for mapped Files. Generates a servlet that has a |
| print statement per line of the JSP file./</td><td>TRUE</td><td>–</td></tr><tr><td>sendErrorToClient</td><td>If false, stack traces, etc., are sent to std error |
| instead of the client's browser.</td><td>FALSE</td><td>–</td></tr><tr><td>classdebuginfo</td><td>Include debugging info in class file.</td><td>TRUE</td><td>–</td></tr><tr><td>checkInterval</td><td>Interval in seconds between background recompile checks. |
| Only relevant if <code class="code"> development=false</code>.</td><td>0</td><td>–</td></tr><tr><td>suppressSmap</td><td>Generation of SMAP info for JSR45 debugging.</td><td>FALSE</td><td>–</td></tr><tr><td>dumpSmap</td><td>Dump SMAP JSR45 info to a file.</td><td>FALSE</td><td>–</td></tr><tr><td>genStrAsCharArray</td><td>Option for generating Strings.</td><td>FALSE</td><td>–</td></tr><tr><td>genStrAsByteArray</td><td>Option for generating Strings.</td><td>TRUE</td><td>–</td></tr><tr><td>defaultBufferNone</td><td> </td><td>FALSE</td><td>–</td></tr><tr><td>errorOnUseBeanInvalidClassAttribute</td><td> </td><td>FALSE</td><td>–</td></tr><tr><td>scratchDir</td><td>Directory where servlets are generated. Jetty sets this |
| value according to the [/display/JETTY/Temporary+Directories |
| work dir] settings for the webapp.</td><td>–</td><td>–</td></tr><tr><td>compiler</td><td>Determined at runtime. For Jetty this is the Eclipse jdt |
| compiler.</td><td>–</td><td>–</td></tr><tr><td>compilerTargetVM</td><td>Target vm to compile for.</td><td>1.5</td><td>–</td></tr><tr><td>compilerSourceVM</td><td>Sets source compliance level for the jdt |
| compiler.</td><td>1.5</td><td>–</td></tr><tr><td>javaEncoding</td><td>Pass through the encoding to use for the |
| compilation.</td><td>UTF8</td><td>–</td></tr><tr><td>modificationTestInterval</td><td>If <code class="code">development=true</code>, interval between |
| recompilation checks, triggered by a request.</td><td>0</td><td>–</td></tr><tr><td>xpoweredBy</td><td>Generate an X-Powered-By response header.</td><td>FALSE</td><td>FALSE</td></tr><tr><td>usePrecompiled/use-precompiled</td><td> </td><td>FALSE</td><td>–</td></tr><tr><td>validating/enableTldValidation</td><td>Whether or not to validate tag files against the |
| schema.</td><td>FALSE</td><td>–</td></tr><tr><td>reload-interval</td><td>If <code class="code">reload-interval=0</code>, then no runtime |
| checking of JSP, otherwise sets the checking interval for both |
| <code class="code">development=true</code> and |
| <code class="code">development=false</code>.</td><td>–</td><td>–</td></tr><tr><td>initial-capacity/initialCapacity</td><td>The initial capacity of the hash maps mapping the name of |
| the JSP to class and JSP file.</td><td>–</td><td>–</td></tr></tbody></table></div></div><br class="table-break"><p>Much confusion generally ensues about the |
| <code class="code">development</code>, <code class="code">checkInterval</code> and <code class="code"> |
| modificationTestInterval</code> parameters and JSP runtime |
| recompilation. Here is a factoring out of the various options:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Check the JSP files for possible recompilation on every |
| request: </p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ |
| |
| <init-param> |
| <param-name>development></param-name> |
| <param-value>true></param-value> |
| </init-param> |
| |
| ]]> |
| </script></div></li><li class="listitem"><p>Only check approximately every N seconds, where a request |
| triggers the time-lapse calculation. This example checks every 60 |
| seconds: </p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ |
| |
| <init-param> |
| <param-name>development></param-name> |
| <param-value>true></param-value> |
| </init-param> |
| <init-param> |
| <param-name>modificationTestInterval></param-name> |
| <param-value>60></param-value> |
| </init-param> |
| |
| ]]> |
| </script></div></li><li class="listitem"><p>Do no checking whatsoever, but still compile the JSP on the |
| very first hit. (Be aware that this ''reload-interval'' parameter is |
| shorthand for a ''development=false'' and ''checkInterval=0'' |
| combination.): </p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ |
| |
| <init-param> |
| <param-name>reload-interval></param-name> |
| <param-value>-1></param-value> |
| </init-param> |
| |
| ]]> |
| </script></div></li><li class="listitem"><p>Don't do any request-time checking, but instead start a |
| background thread to do checks every N seconds. This example checks |
| every 60 seconds: </p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ |
| |
| <init-param> |
| <param-name>development></param-name> |
| <param-value>false></param-value> |
| </init-param> |
| <init-param> |
| <param-name>checkInterval></param-name> |
| <param-value>60></param-value> |
| </init-param> |
| |
| ]]> |
| </script></div></li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="modifying-configuration"></a>Modifying Configuration</h3></div></div></div><p>Regardless of which JSP container you are using, there are several |
| options for modifying the JspServlet configuration.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="overriding-webdefault.xml"></a>Overriding <code class="filename">webdefault.xml</code></h4></div></div></div><p>You can make a copy of the <a class="link" href="webdefault-xml.html" title="webdefault.xml">$JETTY_HOME/etc/webdefault.xml</a> that |
| ships with Jetty, apply your changes, and use it instead of the shipped |
| version. The example below shows how to do this when using the Jetty |
| Maven plugin.</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ |
| |
| <plugin> |
| <groupId>org.eclipse.jetty</groupId> |
| <artifactId>jetty-maven-plugin</artifactId> |
| <configuration> |
| <webApp> |
| <defaultsDescriptor>src/main/resources/webdefault.xml</defaultsDescriptor> |
| </webApp> |
| </plugin> |
| ]]> |
| </script></div><p>If you are using the Jetty distro, and you want to change the JSP |
| settings for just one or a few of your webapps, copy the |
| <code class="filename">$<a class="link" href="webdefault-xml.html" title="webdefault.xml">JETTY_HOME/etc/webdefault.xml</a></code> |
| file somewhere, modify it, and then use a <a class="link" href="quickstart-config-what.html#intro-jetty-configuration-contexts" title="Configuring Contexts">context xml</a> file to |
| set this file as the defaultsDescriptor for your webapp. Here's a |
| snippet:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ |
| |
| <Configure class=>"org.eclipse.jetty.webapp.WebAppContext"> |
| |
| <Set name=>"contextPath">/foo</Set> |
| <Set name=>"war"><SystemProperty name=>"jetty.home" >default=>"."/>/webapps/foobar.war</Set> |
| <Set name=>"defaultsDescriptor">/home/smith/dev/webdefault.xml</Set> |
| |
| </Configure> |
| |
| ]]> |
| </script></div><p>If you want to change the JSP settings for all webapps, edit |
| the<code class="filename"> $JETTY_HOME/etc/webdefaults.xml</code> file directly |
| instead.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="configuring-jsp-servlet-in-web.xml"></a>Configuring the JSP Servlet in |
| <code class="filename">web.xml</code></h4></div></div></div><p>Another option is to add an entry for the JSPServlet to the |
| <code class="filename">WEB-INF/web.xml</code> file of your webapp and change or |
| add init-params. You may also add (but not remove) servlet-mappings. You |
| can use the entry in <a class="link" href="webdefault-xml.html" title="webdefault.xml">$JETTY_HOME/etc/webdefault.xml</a> as a |
| starting point.</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ |
| |
| <servlet id=>"jsp"> |
| <servlet-name>jsp</servlet-name> |
| <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> |
| <init-param> |
| <param-name>logVerbosityLevel</param-name> |
| <param-value>DEBUG</param-value> |
| </init-param> |
| <init-param> |
| <param-name>fork</param-name> |
| <param-value>>false</param-value> |
| </init-param> |
| <init-param> |
| <param-name>keepgenerated</param-name> |
| <param-value>>true</param-value> |
| </init-param> |
| ... |
| |
| <load-on-startup>0</load-on-startup> |
| </servlet> |
| |
| <servlet-mapping> |
| <servlet-name>jsp</servlet-name> |
| <url-pattern>*.jsp</url-pattern> |
| <url-pattern>*.jspf</url-pattern> |
| <url-pattern>*.jspx</url-pattern> |
| <url-pattern>*.xsp</url-pattern> |
| <url-pattern>*.JSP</url-pattern> |
| <url-pattern>*.JSPF</url-pattern> |
| <url-pattern>*.JSPX</url-pattern> |
| <url-pattern>*.XSP</url-pattern> |
| </servlet-mapping> |
| |
| <servlet id=>"my-servlet"> |
| <servlet-name>myServlet</servlet-name> |
| <servlet-class>com.acme.servlet.MyServlet</servlet-class> |
| ... |
| |
| |
| ]]> |
| </script></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="using-jstl-taglibs-for-jetty7-jetty8"></a>Using JSTL Taglibs</h3></div></div></div><p>The JavaServer Pages Standlard Tag Library (JSTL) is part of the |
| Jetty distribution and is automatically put on the classpath when you |
| <a class="link" href="configuring-jsp.html#which-jsp-implementation" title="Which JSP Implementation">select your flavour of |
| JSP</a>. It is also automatically on the classpath for the jetty maven |
| plugin, which uses the Apache JSP engine as of jetty-9.2.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e7335"></a>Embedding</h4></div></div></div><p>If you are using jetty in an embedded scenario, and you need to |
| use JSTL, then you must ensure that the JSTL jars are included on the |
| <span class="emphasis"><em>container's</em></span> classpath - that is the classpath that |
| is the <span class="emphasis"><em>parent</em></span> of the webapp's classpath. This is a |
| restriction that arises from the Java EE specification.</p><p>The jars that you will include will depend on the flavour of JSP |
| that you are using. </p><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e7348"></a>With Glassfish JSP</h5></div></div></div><p>You will need to put the jstl jars that are present in |
| $jetty.home/lib/jsp onto the <span class="emphasis"><em>container's</em></span> |
| classpath. The Glassfish JSP engine will find the jstl tag definitions |
| inside these jars during startup.</p></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e7356"></a>With Apache JSP</h5></div></div></div><p>You will need to put the jars that are present in the |
| $jetty.home/lib/apache-jstl directory onto the |
| <span class="emphasis"><em>container's</em></span> classpath. The Apache JSP engine will |
| find the jstl tag definitions inside these jars during startup.</p><p>As an efficiency enhancement, you can have jetty examine the |
| jstl jars to find the tags, and pre-feed them into the Apache JSP |
| engine. This is more efficient, because jetty will only scan the jars |
| you tell it to, whereas the Apache JSP engine will scan every jar, |
| which can be time-consuming in applications with a lot of jars on the |
| container classpath.</p><p>To take advantage of this efficiency enhancement, set up the |
| <a class="link" href="configuring-webapps.html#container-include-jar-pattern" title="org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern">org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</a> |
| to include a <a class="link" href="http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html" target="_top">pattern</a> |
| that will match the names of the jstl jars. The <a class="link" href="embedded-examples.html" title="Embedded Examples">Embedded Examples</a> section includes |
| a <a class="link" href="embedded-examples.html#embedded-webapp-jsp" title="Web Application with JSP">worked code example</a> of |
| how to do this, here's a snippet from it:</p><div class="informalexample"><p><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[ webapp.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",".*/[^/]*taglibs.*\\.jar$");]]> |
| </script></p></div></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="using-jsf-taglibs"></a>Using JSF Taglibs</h3></div></div></div><p>The following sections provide information about using JSF taglibs |
| with Jetty Standalone and the Jetty Maven Plugin.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="using-jsf-taglibs-with-jetty-standalone"></a>Using JSF Taglibs with Jetty Distribution</h4></div></div></div><p>If you want to use JSF with your webapp, you need to copy the JSF |
| implementation Jar (whichever Jar contains the |
| <code class="filename">META-INF/*.tld</code> files from your chosen JSF |
| implementation) into Jetty's shared container lib directory. You can |
| either put them into the lib directory matching your JSP container of |
| choice (either $JETTY_HOME/lib/jsp for Glassfish JSP, or |
| $JETTY_HOME/lib/apache-jsp for Apache JSP), or put them into |
| $JETTY_HOME/lib/ext.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="using-jsf-taglibs-with-jetty-maven-plugin"></a>Using JSF Taglibs with Jetty Maven Plugin</h4></div></div></div><p>You should make your JSF jars dependencies of the plugin and |
| <span class="emphasis"><em>not</em></span> the webapp itself. For example:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ |
| |
| <plugin> |
| <groupId>org.eclipse.jetty</groupId> |
| <artifactId>jetty-maven-plugin</artifactId> |
| <configuration> |
| <webApp> |
| <contextPath>/${artifactId}</contextPath> |
| </webApp> |
| <scanIntervalSeconds>5</scanIntervalSeconds> |
| </configuration> |
| <dependencies> |
| <dependency> |
| <groupId>com.sun.faces</groupId> |
| <artifactId>jsf-api</artifactId> |
| <version>2.0.8</version> |
| </dependency> |
| <dependency> |
| <groupId>com.sun.faces</groupId> |
| <artifactId>jsf-impl</artifactId> |
| <version>2.0.8</version> |
| </dependency> |
| </dependencies> |
| </plugin> |
| |
| ]]> |
| </script></div></div></div></div></div><script type="text/javascript"> |
| SyntaxHighlighter.all() |
| </script><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="spnego-support.html"><i class="icon-chevron-left"></i> Previous</a> </td><td width="20%" align="center"><a accesskey="u" href="configuring.html"><i class="icon-chevron-up"></i> Top</a></td><td width="40%" align="right"> <a accesskey="n" href="administration.html">Next <i class="icon-chevron-right"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Spnego Support </td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="icon-home"></i> Home</a></td><td width="40%" align="right" valign="top"> Part III. Jetty Administration Guide</td></tr></table></div><p xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><div class="jetty-callout"> |
| See an error or something missing? |
| <span class="callout"><a href="http://github.com/jetty-project/jetty-documentation">Contribute to this documentation at |
| <span class="website"><i class="icon-github"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2015-06-15T13:18:17-05:00)</i></span></div></p><script xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" type="text/javascript"> |
| var _gaq = _gaq || []; |
| _gaq.push(['_setAccount', 'UA-1149868-7']); |
| _gaq.push(['_trackPageview']); |
| |
| (function() { |
| var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
| ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
| var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
| })(); |
| </script></body></html> |