Using friendly URLs without state information

By default, WebSphere® Portal URLs include navigational state information. If you configure pages for friendly URLs, the portal appends the state information to the friendly URLs. Some scenarios require short and fully human readable URLs that omit the state information. For such scenarios you can configure friendly URLs so that the portal does not show that state information.

The state information is an encoded aggregation of the navigational state of the portal, the page and its components, for example, the portlets on the current page:
  • The portal state includes page selection, expansions, label mapping, and action targets.
  • The portlet state includes render parameters, window state, and portlet mode.
The representation of the navigational state within the URL enables characteristics of dynamic web sites, such as usage of bookmarks or the Back button. For example, users can bookmark a page and later return to the exact same state of that page.
Some scenarios require short and fully human readable URLs that omit the state information. Examples:
  • You do not want the URL to make the impression that it references dynamic content.
  • You want the URL to contain only information that a human person can read and interpret.
  • You want the URL to easily fit into the address field of the web browser.
  • Internet search engines expect static URLs that guarantee to reference exactly and only one resource or web page for as long as this page exists
  • Internet search engines prefer short and friendly URLs.
For such scenarios you configure WebSphere Portal as follows:
  • You configure themes to always display only short friendly URLs without the encoded navigational state.
  • You configure pages that use that theme to display friendly URLs.
The configuration applies to all pages that use that theme and that are configured to display friendly URLs.
Note: If you configure your portal to show only stateless friendly URLs, the URLs always point to the default state of a page, as they do not contain the state information.
To configure stateless friendly URLs without state information for your portal, proceed by the following steps:
  1. In the portal WP Configuration Service, set the custom parameter friendly.redirect.enabled to false . You do this by editing the Resource Environment Provider (REP) WPConfigService in the WebSphere Integrated Solutions Console. For information about this parameter and how to set it see Portal configuration services and Setting service configuration properties.
  2. In the theme that you want configure for short stateless URLs, set the parameter com.ibm.portal.theme.hasBaseURL to true . You can update the theme parameter by using the XML configuration interface.
  3. Make sure that all generated URLs in the theme do not include the navigational state. In the default Portal 8.0 theme, you can do this by modifying the file navigation.jsp. By default, this JSP file includes the following code snippet:
    <li class="wpthemeNavListItem wpthemeLeft<c:if test="${wp.selectionModel[node] != null}"> 
               wpthemeSelected</c:if>">
    
    <a href="?uri=nm:oid:${nodeID}" class="wpthemeLeft<c:if test="${childrenStatus.count == 1}"> 
       wpthemeFirst</c:if>" <c:if test="${primeNode}">data-nm-level="${level+1}" 
       data-nm-primed="<portal-fmt:out><portal-core:navigationNodePriming navigationNode="${nodeID}" 
       metaData="${navHiddenMetadata}" considerChildren="false" includeRoles="true" /> 
    </portal-fmt:out>"</c:if>>
    <span lang="${node.title.xmlLocale}" dir="${node.title.direction}">
          <c:choose><c:when test="${node.projectID != null}">(<c:out value="${node.title}"/>)
          </c:when><c:otherwise><c:out value="${node.title}"/></c:otherwise></c:choose>
          <c:if test="${selectedNodeID == nodeID}">
    <span class="wpthemeAccess"> <portal-fmt:text key="currently_selected" bundle="nls8.Theme"/>
    </span></c:if>
    </span></a>
    
    <portal-dynamicui:closePage node="${node}">
       <a class="wpthemeClose wpthemeLeft" href="<%closePageURL.write(out);%>">
       <img alt="X" 
            src="${themeConfig['resources.modules.ibm.contextRoot']}/themes/html/NavigationClose.gif">
      </a>
    </portal-dynamicui:closePage>	
    To generate stateless URLs, replace the middle section of this code snippet in the file navigation.jsp by the update shown in the following snippet:
    <li class="wpthemeNavListItem wpthemeLeft<c:if test="${wp.selectionModel[node] != null}"> 
        wpthemeSelected</c:if>">
    
    <portal-navigation:urlGeneration contentNode="${nodeID}" keepNavigationalState="false">
       <a href="<%wpsURL.write(out);%>" 
          class="wpthemeLeft<c:if test="${childrenStatus.count == 1}"> 
          wpthemeFirst"</c:if>" <c:if test="${primeNode}">data-nm-level="${level+1}" 
          data-nm-primed="<portal-fmt:out><portal-core:navigationNodePriming 
          navigationNode="${nodeID}" metaData="${navHiddenMetadata}" 
          considerChildren="false" includeRoles="true" />
       </portal-fmt:out>"</c:if>>
    <span lang="${node.title.xmlLocale}" dir="${node.title.direction}">
          <c:choose><c:when test="${node.projectID != null}">(<c:out value="${node.title}"/>)
          </c:when><c:otherwise><c:out value="${node.title}"/></c:otherwise>
          </c:choose><c:if test="${selectedNodeID == nodeID}">
    <span class="wpthemeAccess"> <portal-fmt:text key="currently_selected" bundle="nls8.Theme"/>
    </span></c:if>
    </span></a>		
    </portal-navigation:urlGeneration>
    
    <portal-dynamicui:closePage node="${node}">
       <a class="wpthemeClose wpthemeLeft" href="<%closePageURL.write(out);%>">
       <img alt="X" 
            src="${themeConfig['resources.modules.ibm.contextRoot']}/themes/html/NavigationClose.gif">
       </a>
    </portal-dynamicui:closePage>	
  4. Optional: For IBM® Web Content Manager: If you want the IBM Web Content Manager Rendering portlet to also display the friendly and stateless URLs, implement a plug-in that translates the IBM Web Content Manager URLs into the required custom format. For instructions and sample code for such a plug-in see Example 2: Generate a friendly URL for web content in the IBM Web Content Manager documentation.
  5. Set friendly URL names for pages as required. For information about how to do this see Using friendly URLs.
The portal now no longer displays the state information with the URLs.