The urlTemplateFormat property of the DirectUrlTemplate and IndirectUrlTemplate classes is used to specify the format of the URLs generated by the ItemLink servlet bean. In addition, the urlTemplateFormat property of the IndirectUrlTemplate class is used by the jump servlet to determine how to interpret static request URLs created by the servlet bean.

The value of urlTemplateFormat should include placeholders that represent properties of repository items. ItemLink fills in these placeholders when it generates a URL. The jump servlet uses them to extract the property values from a static request URL.

The placeholder format is a parameter name (which typically represents a property of a repository item) inside curly braces. For example, a dynamic URL for displaying a product on a Commerce site might be specified in a direct URL template like this:

urlTemplateFormat=\
  /catalog/product.jsp?prodId\={item.id}&catId\={item.parentCategory.id}

A dynamic URL generated using this format might look like this:

/catalog/product.jsp?prodId=prod1002&catId=cat234

The static URL equivalent in an indirect URL template might look like this:

urlTemplateFormat=/jump/product/{item.id}/{item.parentCategory.id}\
  /{item.displayName}/{item.parentCategory.displayName}

Note that this URL format includes the displayName properties of the repository item and its parent category, and also the repository IDs of these items. The displayName properties provide the text that a web spider can use for indexing. The repository IDs are included so that if an incoming request has this URL, the SEO jump servlet can extract the repository IDs and use them to fill in placeholders in the dynamic URL it generates. In addition, the URL begins with /jump to enable the jump servlet to detect it as a static URL (as described in Specifying Context Paths).

A static URL generated using this format might look like this:

/jump/product/prod1002/cat234/Q33+UltraMountain/Mountain+Bikes
Encoding Parameter Values

By default, the SEO components use URL encoding when they insert parameter values in placeholders. This ensures that special characters in repository item property values do not make the URL invalid. For example, the value of a displayName property will typically include spaces, which are not legal characters in URLs. Therefore, each space is encoded as a plus sign (+), which is a legal character.

In some cases, it is necessary to insert a parameter value unencoded. For example, some repository properties represent partial URL strings, and therefore need to be interpreted literally. To support this, the placeholder syntax allows you to explicitly specify whether to encode a parameter. For example:

{item.template.url,encode=false}

For parameters that should be encoded, you can explicitly specify encode=true; however, this is not necessary, because encode defaults to true.

Another way to specify that a parameter should not be encoded is to use square brackets rather that curly braces. For example:

[item.template.url]
 
loading table of contents...