blob: db45f67ba5eb5f047427e4729c4798ccc2e6bae0 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter&nbsp;8.&nbsp;Configuring JSP Support</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.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"><link rel="up" href="jetty-config-guide.html" title="Part&nbsp;II.&nbsp;Jetty Configuration Guide"><link rel="prev" href="openid-support.html" title="OpenID Support"><link rel="next" href="jetty-admin-guide.html" title="Part&nbsp;III.&nbsp;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"><link rel="stylesheet" href="css/highlighter/foundation.css"><script src="js/highlight.pack.js"></script><script>
hljs.initHighlightingOnLoad();
</script><link type="text/css" rel="stylesheet" href="css/font-awesome/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.4.28-SNAPSHOT</span></td><td style="width: 50%"></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&nbsp;8.&nbsp;Configuring JSP Support</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="openid-support.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;II.&nbsp;Jetty Configuration Guide<br><a accesskey="p" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></th><td width="20%" align="right">&nbsp;<a accesskey="n" href="jetty-admin-guide.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></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 for sponsored feature development
</p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="configuring-jsp"></a>Chapter&nbsp;8.&nbsp;Configuring JSP Support</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><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 class="toc"><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#_precompiling_jsps">Precompiling 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 (JSP) 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>Jetty uses 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.</p><p>By default the Jetty distribution enables the JSP <a class="link" href="startup-modules.html" title="Managing Startup Modules">module</a>, and by default, this module is set to Apache Jasper.</p><pre 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"><code>DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html
[description]
Enables JSP for all webapplications deployed on the server.
[depend]
servlet
annotations
apache-jsp</code></pre><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="_jsps_and_embedding"></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 Apache, 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="_precompiling_jsps"></a>Precompiling JSPs</h3></div></div></div><p>You can either follow the instructions on precompilation provided by Apache, 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 <code class="literal">web.xml</code> file:</p><pre 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"><code> &lt;context-param&gt;
&lt;param-name&gt;org.eclipse.jetty.servlet.jspPackagePrefix&lt;/param-name&gt;
&lt;param-value&gt;com.acme&lt;/param-value&gt;
&lt;/context-param&gt;</code></pre><div class="blockquote"><blockquote class="blockquote"><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="fa fa-asterisk" aria-hidden="true"></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></blockquote></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="compiling-jsps"></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 <code class="literal">{$jetty.home}/lib/apache-jsp</code>.
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="d0e8693"></a><p class="title"><b>Table&nbsp;8.1.&nbsp;Understanding Apache JspServlet Parameters</b></p><div class="table-contents"><table class="table" summary="Understanding Apache JspServlet Parameters" border="1"><colgroup><col class="col_1"><col class="col_2"><col class="col_3"><col class="col_4"></colgroup><thead><tr><th align="left" valign="top">init param</th><th align="left" valign="top">Description</th><th align="left" valign="top">Default</th><th align="left" valign="top"><code class="literal">webdefault.xml</code></th></tr></thead><tbody><tr><td align="left" valign="top"><p>classpath</p></td><td align="left" valign="top"><p><code class="literal">Classpath used for jsp compilation. Only used if
org.apache.catalina.jsp_classpath context attribute is not
set, which it is in Jetty.</code></p></td><td align="left" valign="top"><p>-</p></td><td align="left" valign="top"><p>&#8211;</p></td></tr><tr><td align="left" valign="top"><p>classdebuginfo</p></td><td align="left" valign="top"><p>Include debugging info in class file.</p></td><td align="left" valign="top"><p>TRUE</p></td><td align="left" valign="top"><p>&#8211;</p></td></tr><tr><td align="left" valign="top"><p>checkInterval</p></td><td align="left" valign="top"><p>Interval in seconds between background recompile checks.
Only relevant if `
development=false`.</p></td><td align="left" valign="top"><p>0</p></td><td align="left" valign="top"><p>&#8211;</p></td></tr><tr><td align="left" valign="top"><p>development</p></td><td align="left" valign="top"><p><code class="literal">development=true</code>, recompilation checks occur on each
request. See also `
modificationTestInterval`.</p></td><td align="left" valign="top"><p>TRUE</p></td><td align="left" valign="top"><p>&#8211;</p></td></tr><tr><td align="left" valign="top"><p>displaySourceFragment</p></td><td align="left" valign="top"><p>Should a source fragment be included in
exception messages</p></td><td align="left" valign="top"><p>TRUE</p></td><td align="left" valign="top"><p>&#8211;</p></td></tr><tr><td align="left" valign="top"><p>errorOnUseBeanInvalidClassAttribute</p></td><td align="left" valign="top"><p>Should Jasper issue an error when
the value of the class attribute in an useBean action is not a valid
bean class</p></td><td align="left" valign="top"><p>TRUE</p></td><td align="left" valign="top"><p>&#8211;</p></td></tr><tr><td align="left" valign="top"><p>fork</p></td><td align="left" valign="top"><p>Should Ant fork its Java compiles of JSP pages?</p></td><td align="left" valign="top"><p>TRUE</p></td><td align="left" valign="top"><p>FALSE</p></td></tr><tr><td align="left" valign="top"><p>keepgenerated</p></td><td align="left" valign="top"><p>Do you want to keep the generated Java files around?</p></td><td align="left" valign="top"><p>TRUE</p></td><td align="left" valign="top"><p>&#8211;</p></td></tr><tr><td align="left" valign="top"><p>trimSpaces</p></td><td align="left" valign="top"><p>Should white spaces between directives or actions be
trimmed?</p></td><td align="left" valign="top"><p>FALSE</p></td><td align="left" valign="top"><p>&#8211;</p></td></tr><tr><td align="left" valign="top"><p>enablePooling</p></td><td align="left" valign="top"><p>Determines whether tag handler pooling is enabled.</p></td><td align="left" valign="top"><p>TRUE</p></td><td align="left" valign="top"><p>&#8211;</p></td></tr><tr><td align="left" valign="top"><p>engineOptionsClass</p></td><td align="left" valign="top"><p>Allows specifying the Options class used to
configure Jasper. If not present, the default EmbeddedServletOptions
will be used.</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>mappedFile</p></td></tr><tr><td align="left" valign="top"><p>Support for mapped Files. Generates a servlet that has a
print statement per line of the JSP file&nbsp;</p></td><td align="left" valign="top"><p>TRUE</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>suppressSmap</p></td></tr><tr><td align="left" valign="top"><p>Generation of SMAP info for JSR45 debugging.</p></td><td align="left" valign="top"><p>FALSE</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>dumpSmap</p></td></tr><tr><td align="left" valign="top"><p>Dump SMAP JSR45 info to a file.</p></td><td align="left" valign="top"><p>FALSE</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>genStrAsCharArray</p></td></tr><tr><td align="left" valign="top"><p>Option for generating Strings.</p></td><td align="left" valign="top"><p>FALSE</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>ieClassId</p></td></tr><tr><td align="left" valign="top"><p>The class-id value to be sent to Internet Explorer when
using &lt;jsp:plugin&gt; tags.</p></td><td align="left" valign="top"><p>clsid:8AD9C840-044E-11D1-B3E9-00805F499D93</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>maxLoadedJsps</p></td></tr><tr><td align="left" valign="top"><p>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.</p></td><td align="left" valign="top"><p>-1</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>jspIdleTimeout</p></td></tr><tr><td align="left" valign="top"><p>The amount of time in seconds a JSP can be idle before
it is unloaded. A value of zero or less indicates never unload.</p></td><td align="left" valign="top"><p>-1</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>scratchDir</p></td></tr><tr><td align="left" valign="top"><p>Directory where servlets are generated. See</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>compilerClassName</p></td></tr><tr><td align="left" valign="top"><p>If not set, defaults to the Eclipse jdt compiler.</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>compiler</p></td><td align="left" valign="top"><p>Used if the Eclipse jdt compiler cannot be found on the
classpath. It is the classname of a compiler that Ant should invoke.</p></td></tr><tr><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>compilerTargetVM</p></td><td align="left" valign="top"><p>Target vm to compile for.</p></td></tr><tr><td align="left" valign="top"><p>1.7</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>compilerSourceVM</p></td><td align="left" valign="top"><p>Sets source compliance level for the jdt compiler.</p></td></tr><tr><td align="left" valign="top"><p>1.7</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>javaEncoding</p></td><td align="left" valign="top"><p>Pass through the encoding to use for the compilation.</p></td></tr><tr><td align="left" valign="top"><p>UTF8</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>modificationTestInterval</p></td><td align="left" valign="top"><p>If <code class="literal">development=true</code>, interval between
recompilation checks, triggered by a request.</p></td></tr><tr><td align="left" valign="top"><p>4</p></td><td align="left" valign="top"><p>&#8211;</p></td><td align="left" valign="top"><p>xpoweredBy</p></td><td align="left" valign="top"><p>Generate an X-Powered-By response header.</p></td></tr><tr><td align="left" valign="top"><p>FALSE</p></td><td align="left" valign="top"><p>FALSE</p></td><td align="left" valign="top"><p>recompileOnFail</p></td><td align="left" valign="top"><p>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.</p></td></tr></tbody></table></div></div><br class="table-break"></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="literal">org.apache.jasper.servlet.JspServlet</code> instance defined in the <a class="link" href="webdefault-xml.html" title="webdefault.xml"><code class="literal">webdefault.xml</code></a> file.</p><div class="blockquote"><blockquote class="blockquote"><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="fa fa-asterisk" aria-hidden="true"></i> Note</h3><p>Be careful: for all of these parameters, if the value you set doesn&#8217;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></blockquote></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><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="overriding-webdefault.xml"></a>Overriding <code class="literal">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><pre 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"><code> &lt;plugin&gt;
&lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
&lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
&lt;configuration&gt;
&lt;webApp&gt;
&lt;defaultsDescriptor&gt;src/main/resources/webdefault.xml&lt;/defaultsDescriptor&gt;
&lt;/webApp&gt;
&lt;/plugin&gt;</code></pre><p>If you are using the Jetty distribution, and you want to change the JSP settings for just one or a few of your webapps, copy the <code class="literal">{$jetty.home}/etc/webdefault.xml</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 <code class="literal">defaultsDescriptor</code> for your webapp. Here&#8217;s a snippet:</p><pre 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"><code> &lt;Configure class=&gt;"org.eclipse.jetty.webapp.WebAppContext"&gt;
&lt;Set name=&gt;"contextPath"&gt;/foo&lt;/Set&gt;
&lt;Set name=&gt;"war"&gt;&lt;SystemProperty name=&gt;"jetty.home" &gt;default=&gt;"."/&gt;/webapps/foobar.war&lt;/Set&gt;
&lt;Set name=&gt;"defaultsDescriptor"&gt;/home/smith/dev/webdefault.xml&lt;/Set&gt;
&lt;/Configure&gt;</code></pre><p>If you want to change the JSP settings for all webapps, edit the <code class="literal">{$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 web.xml</h4></div></div></div><p>Another option is to add an entry for the JSPServlet to the <code class="literal">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><pre 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"><code> &lt;servlet id="jsp"&gt;
&lt;servlet-name&gt;jsp&lt;/servlet-name&gt;
&lt;servlet-class&gt;org.apache.jasper.servlet.JspServlet&lt;/servlet-class&gt;
&lt;init-param&gt;
&lt;param-name&gt;logVerbosityLevel&lt;/param-name&gt;
&lt;param-value&gt;DEBUG&lt;/param-value&gt;
&lt;/init-param&gt;
&lt;init-param&gt;
&lt;param-name&gt;fork&lt;/param-name&gt;
&lt;param-value&gt;&gt;false&lt;/param-value&gt;
&lt;/init-param&gt;
&lt;init-param&gt;
&lt;param-name&gt;keepgenerated&lt;/param-name&gt;
&lt;param-value&gt;&gt;true&lt;/param-value&gt;
&lt;/init-param&gt;
...
&lt;load-on-startup&gt;0&lt;/load-on-startup&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
&lt;servlet-name&gt;jsp&lt;/servlet-name&gt;
&lt;url-pattern&gt;*.jsp&lt;/url-pattern&gt;
&lt;url-pattern&gt;*.jspf&lt;/url-pattern&gt;
&lt;url-pattern&gt;*.jspx&lt;/url-pattern&gt;
&lt;url-pattern&gt;*.xsp&lt;/url-pattern&gt;
&lt;url-pattern&gt;*.JSP&lt;/url-pattern&gt;
&lt;url-pattern&gt;*.JSPF&lt;/url-pattern&gt;
&lt;url-pattern&gt;*.JSPX&lt;/url-pattern&gt;
&lt;url-pattern&gt;*.XSP&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
&lt;servlet id="my-servlet"&gt;
&lt;servlet-name&gt;myServlet&lt;/servlet-name&gt;
&lt;servlet-class&gt;com.acme.servlet.MyServlet&lt;/servlet-class&gt;
...</code></pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="jsp-async-support"></a>Configuring Async Support</h4></div></div></div><p>By default, Jetty does not enable async support for the JSP servlet.
Configuring the JSP servlet for async is relatively easy - simply define the <code class="literal">async-supported</code> parameter as <code class="literal">true</code> in either your <code class="literal">webdefault.xml</code> or the <code class="literal">web.xml</code> for a specific context.</p><pre 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"><code>&lt;servlet id="jsp"&gt;
&lt;servlet-name&gt;jsp&lt;/servlet-name&gt;
&lt;async-supported&gt;true&lt;/async-supported&gt;
&lt;/servlet&gt;</code></pre></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.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="_embedding"></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&#8217;s</em></span> classpath - that is the classpath that is the <span class="emphasis"><em>parent</em></span> of the webapp&#8217;s classpath.
This is a restriction that arises from the JavaEE specification.</p><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="_apache_jsp"></a>Apache JSP</h5></div></div></div><p>You will need to put the jars that are present in the <code class="literal">{$jetty.home}/lib/apache-jstl</code> directory onto the <span class="emphasis"><em>container&#8217;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.
Below is a snippet from the example:</p><pre 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"><code> webapp.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",".*/[^/]*taglibs.*\\.jar$");</code></pre></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="literal">META-INF/*.tld</code> files from your chosen JSF implementation) into Jetty&#8217;s shared container lib directory.
You can either put them into the lib directory for Apache <code class="literal">{$jetty.home}/lib/apache-jsp</code> or put them into <code class="literal">{$jetty.home}/lib/ext</code>.</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><pre 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"><code> &lt;plugin&gt;
&lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
&lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
&lt;configuration&gt;
&lt;webApp&gt;
&lt;contextPath&gt;/${artifactId}&lt;/contextPath&gt;
&lt;/webApp&gt;
&lt;scanIntervalSeconds&gt;5&lt;/scanIntervalSeconds&gt;
&lt;/configuration&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
&lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
&lt;version&gt;2.0.8&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
&lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
&lt;version&gt;2.0.8&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;/plugin&gt;</code></pre></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="openid-support.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="jetty-config-guide.html"><i class="fa fa-chevron-up" aria-hidden="true"></i> Top</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="jetty-admin-guide.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr><tr><td width="40%" align="left" valign="top">OpenID Support&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></td><td width="40%" align="right" valign="top">&nbsp;Part&nbsp;III.&nbsp;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/eclipse/jetty.project">Contribute to this documentation at
<span class="website"><i class="fa fa-github" aria-hidden="true"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2020-03-10)</i></span></div></p></body></html>