The Apache Tomcat Servlet/JSP Container

Apache Tomcat 7

Version 7.0.65, Oct 9 2015
Apache Logo


Top Level Elements




Nested Components

Cluster Elements



The Resources Component

Table of Contents

The Resources element represents the web application static resources, from which classes will be loaded, HTML, JSP and the other static files will be served. This allows the webapp to reside on various mediums other than the filesystem, like compressed in a WAR file, in a JDBC database, or in a more advanced versioning repository.

A unified caching engine is provided for all accesses to the webapp resources made by the servlet container and web applications which use the container provided mechanisms to access such resources, such as classloader access, access through the ServletContext interface, or native access through the DirectoryContext interface.

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.

Common Attributes

All implementations of Resources support the following attributes:


Java class name of the implementation to use. This class must implement the interface. It is recommended for optimal functionality and performance, but not mandatory, that the class extend org.apache.naming.resources.BaseDirContext, as well as use the special object types provided in the org.apache.naming.resources for returned objects. If not specified, the standard value (defined below) will be used.

Standard Implementation

The standard implementation of Resources is org.apache.naming.resources.FileDirContext, and is configured by its parent Context element.

VirtualDirContext implementation

This implementation of Resources is org.apache.naming.resources.VirtualDirContext and is aimed to be used during development to deploy a webapp without copying files to a webapp compliant directory structure. It extends FileDirContext and supports the following additional attributes


Allows to map a path of the filesystem to a path in the webapp. Multiple filesystem paths can be mapped to the same path in the webapp. Filesystem path and virtual path must be separated by an equal signe (=). Pairs of paths must be separated by a column.

Example: /=/Users/jdoe/mywebapp/src/main/webapp,/=/Users/jdoe/mywebapp/src/main/webapp2,/pictures=/Users/jdoe/sharedpictures

The path to the docBase (as declared in the Context) must not be added here.

This attribute enhances the feature provided by the aliases attribute of the StandardContext.

Nested Components

No components may be nested inside a Resources element.

Special Features

No special features are associated with a Resources element.


Notice: This comments section collects your suggestions on improving documentation for Apache Tomcat.

If you have trouble and need help, read Find Help page and ask your question on the tomcat-users mailing list. Do not ask such questions here. This is not a Q&A section.

The Apache Comments System is explained here. Comments may be removed by our moderators if they are either implemented or considered invalid/off-topic.

Copyright © 1999-2015, Apache Software Foundation