The Java EE 6 Tutorial

Adding Graphics and Images with the h:graphicImage Tag

In a JavaServer Faces application, use the h:graphicImage tag to render an image on a page:

<h:graphicImage id="mapImage" url="/template/world.jpg"/>

The url attribute specifies the path to the image. The URL of the example tag begins with a /, which adds the relative context path of the web application to the beginning of the path to the image.

Alternatively, you can use the facility described in Resources to point to the image location. Here is an example:

<h:graphicImage value="#{resource['images:wave.med.gif']}"/>