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.jspIn 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:
SiteLinkDropletuses the value of itssiteIdattribute to determine which site it is building a URL for, and then it retrieves theproduction-URLportion of the URL from theproductionURLproperty for that site. In our example, the value ofproductionURLis/crs/storeus. Note that, in this example,productionURLdoes not contain domain information, so the URL thatSiteLinkDropletproduces also does not include this information. Consequently, the browser uses the current page’s protocol, domain, and port for the link.SiteLinkDropletthen appends the value of itspathattribute,/index.jsp, to theproductionURLto create the final URL,/crs/storeus/index.jsp.

