The Resources Component
Table of Contents
Introduction
The Resources element represents all the resources available to the web application. This includes classes, JAR files, HTML, JSPs and any other files that contribute to the web application. Implementations are provided to use directories, JAR files and WARs as the source of these resources and the resources implementation may be extended to provide support for files stored in other forms such as in a database or a versioned repository.
Resources are cached by default.
Note: Running a webapp with non-filesystem based Resources implementations is only possible when the webapp does not rely on direct filesystem access to its own resources, and uses the methods in the ServletContext interface to access them.
A Resources element MAY be nested inside a Context component. If it is not included, a default filesystem based Resources will be created automatically, which is sufficient for most requirements.
Attributes
Common Attributes
All implementations of Resources support the following attributes:
Attribute | Description |
---|---|
allowLinking |
If the value of this flag is 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. |
cacheMaxSize |
The maximum size of the static resource cache in kilobytes.
If not specified, the default value is |
cacheObjectMaxSize |
Maximum size of the static resource that will be placed in the cache.
If not specified, the default value is |
cacheTtl |
The amount of time in milliseconds between the revalidation of cache
entries. If not specified, the default value is |
cachingAllowed |
If the value of this flag is |
className |
Java class name of the implementation to use. This class must
implement the |
trackLockedFiles |
Controls whether the track locked files feature is enabled. If
enabled, all calls to methods that return objects that lock a file and
need to be closed to release that lock (e.g.
If not specified, the default value of |
Standard Implementation
The standard implementation of Resources is org.apache.catalina.webresources.StandardRoot, and is configured by its parent Context element.
Nested Components
A web application's main resources are defined by the docBase defined for the Context. Additional resources may be made available to the web application by defining one or more nested components.
PreResources
PreResources are searched before the main resources. They will be searched in the order they are defined. To configure PreResources, nest a <PreResources> element inside the <Resources> element with the following attributes:
Attribute | Description |
---|---|
base |
Identifies where the resources to be used are located. This attribute
is required by the |
className |
Java class name of the implementation to use. This class must
implement the |
internalPath |
Identifies the path within the base where the
resources are to be found. This is typically only used with JAR files when
the resources are not located at the root of the JAR as is the case with
resource JARs. This attribute is required by the
|
readOnly |
If |
webAppMount |
Identifies the path within the web application that these resources
will be made available. For the
|
JAR resources
JarResources are searched after the main resources but before the PostResources. They will be searched in the order they are defined. To configure JarResources, nest a <JarResources> element inside the <Resources> element. The configuration attributes are the same as for PreResources.
Post-resources
PostResources are searched after the resource JARs. They will be searched in the order they are defined. To configure PostResources, nest a <PostResources> element inside the <Resources> element. The configuration attributes are the same as for PreResources.
Special Features
No special features are associated with a Resources element.