Define references to static content in an MVCPortlet JSP file
According to Portal's portlet programming best practices, all static content asset files, such as images and static HTML, should be included into the portlet application for ease of installation and deployment. However, the MVCPortlet also allows external references to these static contents using a URL defined in the URL provider, with a default JNDI name...
url/com/ibm/commerce/foundation/client/portal/ExternalContent
However, this JNDI name can be overriden by defining a portlet preference, .ExternalContentURLReference.
A JSP tag, <wcp:encodeURL>, is provided to automatically set the URL prefix of the given static content. This tag uses a JNDI name, defaulted to...
url/com/ibm/commerce/foundation/client/portal/ExternalContent
...and can be overriden by using a portlet preference called .ExternalContentURLReference, to resolve the deployed location of static content. This tag takes in two optional attributes as well:
- remote
- States whether to use the URL prefix from the URL provider. The default is true.
- escapeStore
- States whether to exclude the store directory prefix. The default is false.
There are three possible use case scenarios for store related static content:
- On the WebSphere Portal web server. For example:
<wcp:encodeURL url="images/catalog/something.jsp" />
...with external URL reference set to...
http://portal_server_web_server/alias
- Within the MVCPortlet WAR. For example:
<wcp:encodeURL url="images/catalog/something.jsp" remote="false" />
- Remotely on a WebSphere Commerce web server. For example:
<wcp:encodeURL url="images/catalog/something.jsp" />
...with external URL reference set to...
http://hostname/wcsstore
With the additional escapeStore attribute, it is possible to include references to static content which can be used generically across all stores. Setting the escapeStore attribute to "true" will make the tag exclude the store directory in the resulting URL.
The final URL to the static content will be composed of 3 parts:
<protocol + hostname + port + context root or web alias> / <store directory> / <static content relative path>
An example of a non-store specific local static content reference is:
<wcp:encodeURL url="images/something.gif" remote="false" escapeStore="true" />
and this will produce an output of:
/wps/wcportlet/jsp/htimages/something.gif
this URL will be encoded by WebSphere Portal Server.
An example of a store specific remote static content reference is:
<wcp:encodeURL url="images/catalog/something.gif" />
and this will produce an output of:
http://hostname/wcsstore/ConsumerDireimages/catalog/something.jpg
where the URL provider says http://hostname/wcsstore and ConsumerDirect is the store directory used for the current storeId in the business content.
Related concepts
WebSphere Commerce Portal integration and WebSphere Commerce stores
WebSphere Commerce integration with WebSphere Portal
WebSphere Commerce Portal Integration site architecture
Last updated: 25 November 2009