The code sample in this section is a modified version of Commerce Reference Store’s store.war/global/gadgets/
page. It takes a known site ID and creates a URL that follows this pattern:
crossSiteLinkGenerator.jsp
production-URL
/
path-to-static-page
For example:
/crs/storeus/index.jsp
In this example, /crs/storeus
is the production-URL
and /index.jsp
is the path-to-static-page
. Here is the code sample:
<%-- Pass a site ID and path to SiteLinkDroplet to get a static site-specific URL. --%> <dsp:droplet name="/atg/dynamo/droplet/multisite/SiteLinkDroplet" siteId="Site" path="/index.jsp" var="siteLink"/> <dsp:oparam name="output"> <%-- Render the generated URL. --%> <dsp:a href="${siteLink.url}">Go to Store</dsp:a> </dsp:oparam> </dsp:droplet>
The code sample resolves the various portions of the URL as follows:
SiteLinkDroplet
uses the value of itssiteId
attribute to determine which site it is building a URL for, and then it retrieves theproduction-URL
portion of the URL from theproductionURL
property for that site. In our example, the value ofproductionURL
is/crs/storeus
. Note that, in this example,productionURL
does not contain domain information, so the URL thatSiteLinkDroplet
produces also does not include this information. Consequently, the browser will use the current page’s protocol, domain, and port for the link.SiteLinkDroplet
then appends the value of itspath
attribute,/index.jsp
, to theproductionURL
to create the final URL,/crs/storeus/index.jsp
.