J2EE - (Web) Resources

Java Conceptuel Diagram


(Web) Resources are any software artifacts that the web application requires for proper rendering, including:

  • images,
  • script files,
  • and any user-created component libraries.

A Resource may be a javascript file, a css file or a graphic file.

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.


All ressources are located in the standard resource folder called “resources”.

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 resources directory at the web application root: resources/resource-identifier.
  • A resource packaged in the web application’s classpath must be in a subdirectory of the META-INF/resources directory 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.

JSF implementation looks for a directory named resources, either under META-INF or at the root of the WAR file. Then it looks for a subdirectory called css under the resources directory and then for the specified CSS style sheet under that directory.


Resource identifiers are unique strings that conform to the following format:


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.



  • Library Notation
<h:outputStylesheet library="css" name="default.css"/>

This tag specifies that the default.css style sheet is in the directory web/resources/css.

  • Relative Notation
<h:graphicImage value="#{resource['images:myImage.gif']}"/>

This tag specifies that the image named myImage.gif is in the directory web/resources/images.

Documentation / Reference

Discover More
J2ee Ear Structure
Java - Packaging, Archive, Library (JAR, WAR, EAR File)

For deployment purpose, J2EE applications are delivered and reside in Archive files (or unit). A RAR, WAR or EAR file is a standard JAR (.jar) file with a .war or .ear extension. Each archive extension...
Java Conceptuel Diagram
Java - Web Application (Web Module) - War

Web application in Java. A Java web application serve and/or generates interactive HTML web pages. An enterprise application may contain zero or more web applications. A web application is generally...

Share this page:
Follow us:
Task Runner