The Java EE 6 Tutorial, Volume I

Adding Graphics and Images With the h:graphicImage Tag

In a JavaServer Faces application, the Graphic component represents an image. The h:graphicImage tag is used to render a Graphic component 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.

Alternately, you can also use the Resources facility to point to the image location. Here is an example:

<h:graphicImage value="#{resource['']}"/>