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. Caching may be controlled by configuring the appropriate caching attributes on the containing Context.
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 |
---|---|
className |
Java class name of the implementation to use. This class must
implement the |
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
|
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.