The Context Container
Introduction
The Context element represents a web application, which is run within a particular virtual host. Each web application is based on a Web Application Archive (WAR) file, or a corresponding directory containing the corresponding unpacked contents, as described in the Servlet Specification (version 2.2 or later). For more information about web application archives, you can download the Servlet Specification, and review the JBoss Web Application Developer's Guide.
The web application used to process each HTTP request is selected
by Catalina based on matching the longest possible prefix of the
Request URI against the context path of each defined Context.
Once selected, that Context will select an appropriate servlet to
process the incoming request, according to the servlet mappings defined
in the web application deployment descriptor file (which MUST
be located at /WEB-INF/web.xml
within the web app's
directory hierarchy).
You may define as many Context elements as you wish. Each such Context MUST have a unique context path. In addition, a Context must be present with a context path equal to a zero-length string. This Context becomes the default web application for this virtual host, and is used to process all requests that do not match any other Context's context path.
In AS7 the file context.xml is ignored Most of the old context.xml configuration has been moved to jboss-web.xml (See jboss-web.xml).
Attributes
Common Attributes
All implementations of Context support the following attributes:
Attribute Description 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. The value of this attribut is 10 seconds.
className
Java class name of the implementation to use. This class must implement the
org.apache.catalina.Context
interface. org.apache.catalina.core.StandardContext is used.cookies
To control the cookies use
session-config
in web.xmlcrossContext
Use
disable-cross-context
in jboss-web.xmlSet to
false
if you want calls within this application toServletContext.getContext()
to successfully return a request dispatcher for other web applications running on this virtual host. Set totrue
(the default) in security conscious environments, to makegetContext()
always returnnull
.docBase
Can't be changed in AS7
override
Not supported in AS7
privileged
Not supported in AS7
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. Use
context-root
in jboss-web.xml to configure that in AS7.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. In AS7 you can use use thedeployment-scanner
in standalone.xml ordevelopment
in the jsp-configuration element inside the subsystem=web element.wrapperClass
Java class name of the
org.apache.catalina.Wrapper
implementation class that will be used for servlets managed by this Context.org.apache.catalina.core.StandardWrapper
is used.
Standard Implementation
The standard implementation of Context is org.apache.catalina.core.StandardContext. It supports the following additional attributes (in addition to the common attributes listed above):
Attribute Description allowLinking
Actually not supported in AS7
If the value of this flag is
true
, symlinks will be allowed inside the web application, pointing to resources outside the web application base path. If not specified, the default value of the flag isfalse
.NOTE: This flag MUST NOT be set to true on the Windows platform (or any other OS which does not have a case sensitive filesystem), as it will disable case sensitivity checks, allowing JSP source code disclosure, among other security problems.
antiJARLocking
Not supported in AS7
antiResourceLocking
Not supported in AS7
cacheMaxSize
Maximum size of the static resource cache in kilobytes. The default value is
10240
(10 megabytes) is used in AS7.cacheTTL
Amount of time in milliseconds between cache entries revalidation. The default value is
5000
(5 seconds) is used in AS7.cachingAllowed
If the value of this flag is
true
, the cache for static resources will be used. The default valuetrue
is used in AS7.caseSensitive
If the value of this flag is
true
, all case sensitivity checks will be disabled. If not specified, the default value of the flag istrue
.NOTE: This flag MUST NOT be set to false on the Windows platform (or any other OS which does not have a case sensitive filesystem), as it will disable case sensitivity checks, allowing JSP source code disclosure, among other security problems. The default value
true
is used in AS7.processTlds
Whether the context should process TLDs on startup. The default is true. The false setting is intended for special cases that know in advance TLDs are not part of the webapp. The default value
true
is used in AS7.swallowOutput
Not supported in AS7. The outputs go to server.log file
tldNamespaceAware
Not supported in AS7
tldValidation
Not supported in AS7
unloadDelay
Not supported in AS7
unpackWAR
Not supported in AS7
AS7 will unpack all compressed web applications before running them.
useNaming
Not supported in AS7
workDir
Pathname to a scratch directory to be provided by this Context for temporary read-write use by servlets within the associated web application. This directory will be made visible to servlets in the web application by a servlet context attribute (of type
java.io.File
) namedjavax.servlet.context.tempdir
as described in the Servlet Specification. In AS7 something likestandalone/tmp/work/jboss.web
is used.
Special Features
jboss-web.xml
In AS7 most of the feature of
context.xml
are now injboss-web.xml
. See jboss-web.xml for more information.