WebSphere Portal 8: Remove State Information From Friendly URL

By default, WebSphere Portal 8 will include navigational state information. While state information comes in handy by retaining the page’s state, it is often redeemed by our clients as messy and gibberish especially for public facing websites. An example of url with state information:

http://10.10.10.18:10039/wps/portal/test/!ut/p/a1/hc5BDoIwEAXQs3iCfptSyhIpUIyKRBO1G8OCYBOkBtDzWwwbF-LsJnl__hBNzkS35cvU5WBsWzakiLvOdoeq791-NPfKPocRaX7N9zJdUkHXqUqAMM89hsIHJHXg4gB-TIhPPkpDxfwNIKSMkMlVwHfcA2JM-Rnwp_9E9HcFmKDjBSX9YAtkfAIzLz5uTRJk9eINqfbQ7A!!/dl5/d5/L2dBISEvZ0FBIS9nQSEh/

Before we proceed, try this! Access your page’s url without state information. You will realize that you will be redirected to an url with state information.

Step 1: Add/Edit “friendly.redirect.enabled” Property in WebSphere Integrated Solutions Console:

  1. Login to WebSphere Integrated Solutions Console (https://<server ip>:<port:10041>/ibm/console).
  2. Click on “Resource Environment Provider“, under “Resources > Resource Environment > Resource Environment Providers“.
  3. Search for “WPConfigService” and click on it.
  4. Click on the “Custom Properties“.
  5. Search for “friendly.redirect.enabled” property. By default the property does not exists, add in “friendly.redirect.enabled” and set it to false (type as string).
  6. Save the setting to master configuration.
  7. Restart the server.

Step 2: Update Theme Parameter via XML Access

  1. Go to <PortalServer folder>\doc\xml-samples folder (for example: C:\IBM\WebSphere\PortalServer\doc\xml-samples).
  2. Locate ExportThemesAndSkins.xml and copy the file to <PortalServer folder>\bin folder.
  3. Open your cmd prompt and go to <PortalServer folder>\bin and key in the following command (press enter):
    xmlaccess.bat -in ExportThemesAndSkins.xml -out result.xml -user <wpsadmin's name> -password <wpsadmin's password> -url http://<server ip>:<port:10039>/wps/config
  4. Edit result.xml in notepad and locate the theme that you wish to remove the state information and add in ‘<parameter name=”com.ibm.portal.theme.hasBaseURL” type=”string” update=”set”>true</parameter>’ under the <theme> node (see example below).
    <?xml version="1.0" encoding="UTF-8"?>
    
    <request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PortalConfig_8.0.0.xsd" type="update">
       <!-- This sample sets the hasBaseURL Tag in the Portal 8 Theme. -->
       <portal action="locate">
          <theme action="update" uniquename="ibm.portal.80Theme" >
             <parameter name="com.ibm.portal.theme.hasBaseURL" 
                        type="string" update="set">true</parameter>
          </theme>
       </portal>
    </request>
  5. Rename your result.xml to configureTheme.xml (naming doesn’t matter).
  6. At your cmd prompt and execute the following cmd.
    xmlaccess.bat -in configureTheme.xml -out result.xml -user <wpsadmin's name> -password <wpsadmin's password> -url http://<server ip>:<port:10039>/wps/config
  7. You should be able to see the following response in your cmd prompt:
  8. To verify access one of the page’s url that is using the default theme without the state information (for example: http://10.10.10.18:10039/wps/portal/test). You will realize that you are no longer been redirect to a url with state information.
    Note: if you click on any of the links in the theme, you will still be directed to an url with state information and this brings us to the next step.

Step 3: Update Theme Dynamic Content Spots

  1. Go to <PortalServer folder>\theme\wp.theme.themes\default80\installedApps\DefaultTheme80.ear\DefaultTheme80.war\themes\html\dynamicSpots.
  2. Open navigation.jsp with an editor (would prefer Notepad++).
  3. Search for the string “<a href=”?uri=nm:oid:${nodeID}” and replace it with the following string:
    <a href="<portal-navigation:urlGeneration contentNode="${nodeID}" keepNavigationalState="false"><%wpsURL.write(out);%></portal-navigation:urlGeneration>"
  4. Repeat Step 2 and 3 with sideNavigation.jsp (in the same folder as navigation.jsp).

Step 4: Ensure that all of your pages have friendly name

  1. Scan thru all of your pages and ensure that they have friendly URL name.
  2. Congrats! You are done with this excerise!

References:

3 thoughts on “WebSphere Portal 8: Remove State Information From Friendly URL”

  1. Hi Team,

    Want to change custom theme navigation.jsp not in portal default theme, Please explain for portal 8.5 for clean and short URL.

    1. Hi Amit,

      Above example will works for WebSphere Portal 8.5 except that the navigation.jsp is in \theme\wp.theme.themes\default85\installedApps\DefaultTheme85.ear\DefaultTheme85.war\themes\html\dynamicSpots.

Leave a Reply

Your email address will not be published. Required fields are marked *