The Java EE 7 Tutorial
Web resources are any software artifacts that the web application requires for proper rendering, including images, script files, and any user-created component libraries. Resources must be collected in a standard location, which can be one of the following.
A resource packaged in the web application root must be in a subdirectory of a
resourcesdirectory at the web application root:
A resource packaged in the web application's classpath must be in a subdirectory of the
META-INF/resourcesdirectory within a web application:
META-INF/resources/resource-identifier. You can use this file structure to package resources in a JAR file bundled in the web application.
The JavaServer Faces runtime will look for the resources in the preceding listed locations, in that order.
Resource identifiers are unique strings that conform to the following format (all on one line):
Elements of the resource identifier in brackets (
) are optional, indicating that only a resource-name, which is usually a file name, is a required element. For example, the most common way to specify a style sheet, image, or script is to use the
name attributes, as in the following tag from the
<h:outputStylesheet library="css" name="default.css"/>
This tag specifies that the
default.css style sheet is in the directory
You can also specify the location of an image using the following syntax, also from the
This tag specifies that the image named
wave.med.gif is in the directory
Resources can be considered as a library location. Any artifact, such as a composite component or a template that is stored in the
resources directory, becomes accessible to the other application components, which can use it to create a resource instance.