You are here: Reference > Streams and JSP > JavaServer Pages tags > contentURL

  contentURL JavaServer Page tag

Use the contentURL JSP tag to include a system-generated cleartext URL in the current stream that requests an image saved in an image content data instance (Data-Content-Image class). This is a reusable, unhashed URL that can be used more than once to refer to the image.

For example:

<img src='<pega:contentURL name="filename.fileType" path="/filePath/" classType="Image" />' >

Generates the following cleartext URL:

<img src=’../datacontent/Image/filePath/fileName.fileType’>

An image retrieved from an Image Content instance is the same for all requestors.

Example

For an example, review the standard HTML rule @baseclass.Operator-Profile-Full. This rule supports the display of operator images in the View > My Profile display. If an image content data instance for an operator is associated with an operator ID, that file is retrieved and included in the My Profile display. If no data content data instance is associated with the operator ID, the default image from the binary file rule image.dialogprofileimage.gif appears.

Complete syntax

In the syntax presentation below:

<pega:contentURL name="filename.filetype"
   [path="filepath" ]
   classType = "Image"
   [ enforceAbsoluteURL = "true|false" ]
/>

The name and classType attributes are required.

Attribute

Value

name

Second key part (File Name) and third key part (File Type) of an image content data instance.

path

First key part (File Path) of an image content instance. Note that each path value starts and ends with a forward slash character. If the path is blank, this attribute can be omitted.

classType

"Image" is the only allowed value. .

enforceAbsoluteURL

Optional (only necessary for unusual situations). An absolute URL may be needed in unusual situations where the base URL of the HTML page containing the tag differs from typical structure. Set to "true" to generate an absolute HTTP URL. For example:

<img src='<pega:contentURL name="filename.fileType" path="/filePath/" classType="Image" />' >

Will result in:

<img src=’http://myserver:8080/prweb/datacontent/Image/filePath/fileName.fileType’>

If false, the system generates a relative URL. The default if this attribute omitted is "false".

Notes

The contentURL tag generates a URL, not an <img ..> tag. To present an image, include the contentURL within an <img > tag, as shown above.

Definitions stream processing
Related topics About Image Content data instances

JavaServer Page tags