3 Replies Latest reply on Jun 24, 2009 2:27 PM by Andy Pemberton

    XML Escaping resourceURLs

    Craig Dickson Newbie

      I am attempting to deploy a very simple portlet onto JBoss Portal 2.7.2 (running on Mac OSX).

      There is a requirement for the resulting HTML to be XHTML 1.0 Strict compliant.

      Within the portlet I have a snippet of JavaScript that is designed to dynamically submit an asynchronous GET request using a JQuery library.

      However, when using the

      <portlet:resourceURL/>
      tag to help create the URL to send the request to, I notice that the ampersands in the URL are not encoded properly and so validating the HTML is failing.

      I have tried changing the use of the tag to
      <portlet:resourceURL escapeXml="true"/>
      .

      I have also tried passing the javax.portlet.escapeXml system property on the JBoss command line by adding the following to my run.sh script:

      JAVA_OPTS="-Djavax.portlet.escapeXml=true $JAVA_OPTS"


      But nothing seems to make any difference.

      And the worst part is, it appears that even the ampersands that I have been hand encoding are being converted back to unencoded ampersands. For example, in the JavaScript, I want to dynamically append one more request parameter to the URL that is generated by the <portlet:resourceURL/> tag like this:

      var url = "<portlet:resourceURL/>&name=" + name;


      However, the encoded ampersand before the name parameter gets simply converted to a single ampersand character when I view the source through Firebug etc. Like this:

      var url = "/portal/auth/portal/default/Theme+Test/Quick+Extension+LookupWindow_90?action=b&cacheability=PAGE&name=" + name;


      The actual JS code runs fine, but the page is failing the XHTML validation, which is a showstopper.

      What am I missing?

      Thanks