The SiteURLManager can generate URLs from site IDs, typically on requests from Oracle ATG Web Commerce servlet beans such as SiteLinkDroplet
(see the ATG Page Developer's Guide). Given a site ID and path, you can use this servlet bean to write page code that generates links to different sites and paths. To create these links, the SiteURLManager maintains a map keyed by site IDs that are paired with URLs.
URL Construction Rules
The SiteURLManager constructs URLs for a requested site according to the following rules:
No path supplied: New URL retains old path relative to the new site’s root.
Path contains leading forward slash (
/
): Path is relative to the new site’s root.Path omits leading forward slash (
/
): Path is relative to the current page, on the new site.
URL construction varies depending on whether production site URLs conform to a domain-based or path-based convention (see Production Site URL Conventions). The following examples show how SiteLinkDroplet generates URLs according to these diferent conventions.
Production-Site URLs Use Path-Based Strategy
Target site’s production site URL:/foo
Current URL:http://domain.com/bar/dir/index.jsp
Input path | New URL |
---|---|
|
|
|
|
|
|
|
|
Production-Site URLs Use Domain-Based Strategy
Target site’s production site URL:foo.com
Current URL:http://domain.com/dir/index.jsp
Input path | New URL |
---|---|
|
|
|
|
|
|
|
|
Sticky Site Parameters
A sticky site is specified through special URL query parameters pushSite
and stickySite
(see RequestParameterRuleFilter earlier in this chapter). Links that are generated on a preview server automatically include these query parameters through the SiteURLManager property autoAppendStickySiteParams
. The generated link retains the root of the current site; the URL path is modified according to the URL Construction Rules described in the previous section.
Note: A preview server should always set its SiteURLManager property autoAppendStickySiteParams
to true
; changing this property to false
can yield unpredictable results.
The following examples show how the SiteURLManager generates links, given a site ID of fbar
and this current URL:
http://domain.com/root/path/index.jsp
Input path | New URL |
---|---|
|
|
|
|
|
|
|
|
getProductionSiteBaseURL()
You can also obtain site URLs by calling SiteURLManager
.getProductionSiteBaseURL()
, which, given a DynamoHttpServletRequest and a site ID, returns an absolute URL based on the URL Construction Rules described earlier.
This method has the following signature:
public String getProductionSiteBaseURL(DynamoHttpServletRequest pRequest, String pSiteId, String pPath, String pQueryParams, String pProtocol, boolean pInInclude)
getProductionSiteBaseURL()
takes the following optional parameters:
Parameter | Description |
---|---|
| Path string to include in the returned URL. |
| Query parameters to include in the returned URL. |
| The protocol to use— |
| A Boolean flag, specifies whether relative paths should use the URI of the included page. |
Note: If a site ID contains unconventional characters—for example, hash (#
) and plus (+
)—you can enter them directly for the pSiteID
parameter and the equivalent input parameter in Oracle ATG Web Commerce servlets. However, settings for the pPath
parameter and query parameters must use URL encoding for non-alphanumeric characters—for example, %40
and %7E
for at (@
) and tilde (~
) characters, respectively.
SiteBaseURLProcessors
When required to generate a URL, the SiteURLManager executes an array of SiteBaseURLProcessor components, specified through its siteBaseURLProcessors
property. The Oracle ATG Web Commerce installation provides two processors: