Apache Tomcat 8 Configuration Reference (8.5.100)
allowCasualMultipartParsing
Set to true if Tomcat should automatically parse
multipart/form-data request bodies when HttpServletRequest.getPart*
or HttpServletRequest.getParameter* is called, even when the
target servlet isn't marked with the @MultipartConfig annotation
(See Servlet Specification 3.0, Section 3.2 for details).
Note that any setting other than false causes Tomcat
to behave in a way that is not technically spec-compliant.
The default is false.
allowMultipleLeadingForwardSlashInPath
Tomcat normalises sequences of multiple / characters in
a URI to a single /. This is for consistency with the
behaviour of file systems as URIs are often translated to file system
paths. As a result, the return value of
HttpServletRequest#getContextPath() is expected to start
with multiple / characters for some URIs. This will cause
problems if this value is used directly with
HttpServletResponse#sendRedirect() as redirect paths that
start with // are treated as protocol relative redirects.
To avoid potential issues, Tomcat will collapse multiple leading
/ characters at the start of the return value for
HttpServletRequest#getContextPath() to a single
/. This attribute has a default value of false
which enables the collapsing of multiple / characters. To
disable this behaviour, set this attribute to true.
altDDName
The absolute path to the alternative deployment descriptor for this
context. This overrides the default deployment descriptor located at
/WEB-INF/web.xml.
backgroundProcessorDelay
This value represents the delay in seconds between the invocation of the backgroundProcess method on this context and its child containers, including all wrappers. Child containers will not be invoked if their delay value is not negative (which would mean they are using their own processing thread). Setting this to a positive value will cause a thread to be spawn. After waiting the specified amount of time, the thread will invoke the backgroundProcess method on this host and all its child containers. A context will use background processing to perform session expiration and class monitoring for reloading. If not specified, the default value for this attribute is -1, which means the context will rely on the background processing thread of its parent host.
className
Java class name of the implementation to use. This class must
implement the org.apache.catalina.Context interface.
If not specified, the standard value (defined below) will be used.
containerSciFilter
The regular expression that specifies which container provided SCIs
should be filtered out and not used for this context. Matching uses
java.util.regex.Matcher.find() so the regular expression
only has to match a sub-string of the fully qualified class name of the
container provided SCI for it to be filtered out. If not specified,
no filtering will be applied.
cookies
Set to true if you want cookies to be used for
session identifier communication if supported by the client (this
is the default). Set to false if you want to disable
the use of cookies for session identifier communication, and rely
only on URL rewriting by the application.
createUploadTargets
Set to true if Tomcat should attempt to create the
temporary upload location specified in the MultipartConfig
for a Servlet if the location does not already exist. If not specified,
the default value of false will be used.
crossContext
Set to true if you want calls within this application
to ServletContext.getContext() to successfully return a
request dispatcher for other web applications running on this virtual
host. Set to false (the default) in security
conscious environments, to make getContext() always
return null.
docBase
The Document Base (also known as the Context
Root) directory for this web application, or the pathname
to the web application archive file (if this web application is
being executed directly from the WAR file). You may specify
an absolute pathname for this directory or WAR file, or a pathname
that is relative to the appBase directory of the
owning Host.
The value of this field must not be set unless the Context element is
defined in server.xml or the docBase is not located under
the Host's appBase.
If a symbolic link is used for docBase then changes to
the symbolic link will only be effective after a Tomcat restart or
by undeploying and redeploying the context. A context reload is not
sufficient.
dispatchersUseEncodedPaths
Controls whether paths used in calls to obtain a request dispatcher
ares expected to be encoded. This affects both how Tomcat handles calls
to obtain a request dispatcher as well as how Tomcat generates paths
used to obtain request dispatchers internally. If not specified, the
default value of true is used. When encoding/decoding paths
for a request dispatcher, UTF-8 is always used.
failCtxIfServletStartFails
Set to true to have the context fail its startup if any
servlet that has load-on-startup >=0 fails its own startup.
If not specified, the attribute of the same name in the parent Host
configuration is used if specified. Otherwise the default value of
false is used.
fireRequestListenersOnForwards
Set to true to fire any configured
ServletRequestListeners when Tomcat forwards a request. This is
primarily of use to users of CDI frameworks that use
ServletRequestListeners to configure the necessary environment for a
request. If not specified, the default value of false is
used.
logEffectiveWebXml
Set to true if you want the effective web.xml used for a
web application to be logged (at INFO level) when the application
starts. The effective web.xml is the result of combining the
application's web.xml with any defaults configured by Tomcat and any
web-fragment.xml files and annotations discovered. If not specified, the
default value of false is used.
mapperContextRootRedirectEnabled
If enabled, requests for a web application context root will be
redirected (adding a trailing slash) if necessary by the Mapper rather
than the default Servlet. This is more efficient but has the side effect
of confirming that the context path exists. If not specified, the
default value of true is used.
mapperDirectoryRedirectEnabled
If enabled, requests for a web application directory will be
redirected (adding a trailing slash) if necessary by the Mapper rather
than the default Servlet. This is more efficient but has the side effect
of confirming that the directory is exists. If not specified, the
default value of false is used.
override
Set to true to ignore any settings in both the global
or Host default contexts. By default, settings
from a default context will be used but may be overridden by a setting
the same attribute explicitly for the Context.
path
The context path of this web application, which is matched against the beginning of each request URI to select the appropriate web application for processing. All of the context paths within a particular Host must be unique. If you specify a context path of an empty string (""), you are defining the default web application for this Host, which will process all requests not assigned to other Contexts.
This attribute must only be used when statically defining a Context
in server.xml. In all other circumstances, the path will be inferred
from the filenames used for either the .xml context file or the
docBase.
Even when statically defining a Context in server.xml, this attribute
must not be set unless either the docBase is not located
under the Host's appBase or
both deployOnStartup and autoDeploy are
false. If this rule is not followed, double deployment is
likely to result.
preemptiveAuthentication
When set to true and the user presents credentials for a
resource that is not protected by a security constraint, if the
authenticator supports preemptive authentication (the standard
authenticators provided with Tomcat do) then the user' credentials
will be processed. If not specified, the default of false is
used.
privileged
Set to true to allow this context to use container
servlets, like the manager servlet. Use of the privileged
attribute will change the context's parent class loader to be the
Server class loader rather than the Shared class
loader. Note that in a default installation, the Common class
loader is used for both the Server and the Shared
class loaders.
reloadable
Set to true if you want Catalina to monitor classes in
/WEB-INF/classes/ and /WEB-INF/lib for
changes, and automatically reload the web application if a change
is detected. This feature is very useful during application
development, but it requires significant runtime overhead and is
not recommended for use on deployed production applications. That's
why the default setting for this attribute is false. You
can use the Manager web
application, however, to trigger reloads of deployed applications
on demand.
resourceOnlyServlets
Comma separated list of Servlet names (as used in
/WEB-INF/web.xml) that expect a resource to be present.
Ensures that welcome files associated with Servlets that expect a
resource to be present (such as the JSP Servlet) are not used when there
is no resource present. This prevents issues caused by the clarification
of welcome file mapping in section 10.10 of the Servlet 3.0
specification. If the
org.apache.catalina.STRICT_SERVLET_COMPLIANCE
system property is set to
true, the default value of this attribute will be the empty
string, else the default value will be jsp.
sendRedirectBody
If true, redirect responses will include a short
response body that includes details of the redirect as recommended by
RFC 2616. This is disabled by default since including a response body
may cause problems for some application component such as compression
filters.
sessionCookieDomain
The domain to be used for all session cookies created for this context. If set, this overrides any domain set by the web application. If not set, the value specified by the web application, if any, will be used.
sessionCookieName
The name to be used for all session cookies created for this
context. If set, this overrides any name set by the web application.
If not set, the value specified by the web application, if any, will be
used, or the name JSESSIONID if the web application does
not explicitly set one.
sessionCookiePath
The path to be used for all session cookies created for this
context. If set, this overrides any path set by the web application.
If not set, the value specified by the web application will be used, or
the context path used if the web application does not explicitly set
one. To configure all web application to use an empty path (this can be
useful for portlet specification implementations) set this attribute to
/ in the global CATALINA_BASE/conf/context.xml
file.
Note: Once one web application using
sessionCookiePath="/" obtains a session, all
subsequent sessions for any other web application in the same host also
configured with sessionCookiePath="/" will always
use the same session ID. This holds even if the session is invalidated
and a new one created. This makes session fixation protection more
difficult and requires custom, Tomcat specific code to change the
session ID shared by the multiple applications.
sessionCookiePathUsesTrailingSlash
Some browsers, such as Internet Explorer, Safari and Edge, will send
a session cookie for a context with a path of /foo with a
request to /foobar in violation of RFC6265. This could
expose a session ID from an application deployed at /foo to
an application deployed at /foobar. If the application
deployed at /foobar is untrusted, this could create a
security risk. However, it should be noted that RFC 6265, section 8.5
makes clear that path alone should not be view as sufficient to prevent
untrusted applications accessing cookies from other applications. To
mitigate this risk, this attribute may be set to true and
Tomcat will add a trailing slash to the path associated with the session
cookie so, in the above example, the cookie path becomes /foo/. However,
with a cookie path of /foo/, browsers will no longer send the cookie
with a request to /foo. This should not be a problem unless there is a
servlet mapped to /*. In this case this attribute will need to be set to
false to disable this feature. The default value for this
attribute is false.
swallowAbortedUploads
Set to false if Tomcat should not read any
additional request body data for aborted uploads and instead abort the
client connection. This setting is used in the following situations:
- the size of the request body is larger than the
maxPostSizeconfigured in the connector - the size limit of a MultiPart upload is reached
- the servlet sets the response status to 413 (Request Entity Too Large)
Not reading the additional data will free the request processing thread more quickly. Unfortunately most HTTP clients will not read the response if they cannot write the full request.
The default is true, so additional data will be
read.
Note if an error occurs during the request processing that triggers a 5xx response, any unread request data will always be ignored and the client connection will be closed once the error response has been written.
swallowOutput
If the value of this flag is true, the bytes output to
System.out and System.err by the web application will be redirected to
the web application logger. If not specified, the default value
of the flag is false.
tldValidation
If the value of this flag is true, the TLD files
will be XML validated on context startup. If the
org.apache.catalina.STRICT_SERVLET_COMPLIANCE
system property is set to
true, the default value of this attribute will be
true, else the default value will be false.
Setting this attribute to true will incur a performance
penalty.
useHttpOnly
Should the HttpOnly flag be set on session cookies to prevent client
side script from accessing the session ID? Defaults to
true.
useRelativeRedirects
Controls whether HTTP 1.1 and later location headers generated by a
call to
javax.servlet.http.HttpServletResponse#sendRedirect(String)
will use relative or absolute redirects. Relative redirects are more
efficient but may not work with reverse proxies that change the context
path. It should be noted that it is not recommended to use a reverse
proxy to change the context path because of the multiple issues it
creates. Absolute redirects should work with reverse proxies that change
the context path but may cause issues with the
org.apache.catalina.filters.RemoteIpFilter if the filter is
changing the scheme and/or port. If the
org.apache.catalina.STRICT_SERVLET_COMPLIANCE
system property is set to
true, the default value of this attribute will be
false, else the default value will be true.
validateClientProvidedNewSessionId
When a client provides the ID for a new session, this attribute controls whether that ID is validated. The only use case for using a client provided session ID is to have a common session ID across multiple web applications. Therefore, any client provided session ID should already exist in another web application. If this check is enabled, the client provided session ID will only be used if the session ID exists in at least one other web application for the current host. Note that the following additional tests are always applied, irrespective of this setting:
- The session ID is provided by a cookie
- The session cookie has a path of {@code /}
If not specified, the default value of true will be
used.
wrapperClass
Java class name of the org.apache.catalina.Wrapper
implementation class that will be used for servlets managed by this
Context. If not specified, a standard default value will be used.
xmlBlockExternal
If the value of this flag is true, the parsing of
web.xml, web-fragment.xml, *.tld,
*.jspx, *.tagx and tagPlugins.xml
files for this web application will not permit external entities to be
loaded. If not specified, the default value of true will
be used.
xmlNamespaceAware
If the value of this flag is true, the parsing of
web.xml and web-fragment.xml files for this
web application will be namespace-aware. Note that *.tld,
*.jspx and *.tagx files are always parsed
using a namespace-aware parser and that the tagPlugins.xml
file (if any) is never parsed using a namespace-aware parser. Note also
that if you turn this flag on, you should probably also turn
xmlValidation on. If the
org.apache.catalina.STRICT_SERVLET_COMPLIANCE
system property is set to
true, the default value of this attribute will be
true, else the default value will be false.
Setting this attribute to true will incur a performance
penalty.
xmlValidation
If the value of this flag is true, the parsing of
web.xml and web-fragment.xml files for this
web application will use a validating parser. If the
org.apache.catalina.STRICT_SERVLET_COMPLIANCE
system property is set to
true, the default value of this attribute will be
true, else the default value will be false.
Setting this attribute to true will incur a performance
penalty.