Re: [xsl] url rewriting

Subject: Re: [xsl] url rewriting
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Sun, 01 Dec 2002 22:34:50 +0100
We solve this in our applications via a named template:

<a>
  <xsl:attribute name="href">
    <xsl:call-template name="url-rewriting">
      <xsl:with-param name="url" select="'http://www.foo.bar'"/>
    </xsl:call-template>
  </xsl:attribute>
</a>

---

<xsl:template name="url-rewriting">
  <xsl:param name="url" select="''"/>
  <xsl:choose>
    <xsl:when test="contains($url, '?')">
      <xsl:value-of select="substring-before($url, '?')"/>
      <xsl:text>;jsessionid=</xsl:text>
      <xsl:value-of select="$sessionid"/>
      <xsl:value-of select="substring-after($url, '?')"/>
    </xsl:when>
    <xsl:when test="contains($url, '#')">
      <xsl:value-of select="substring-before($url, '#')"/>
      <xsl:text>;jsessionid=</xsl:text>
      <xsl:value-of select="$sessionid"/>
      <xsl:value-of select="substring-after($url, '#')"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$url"/>
      <xsl:text>;jsessionid=</xsl:text>
      <xsl:value-of select="$sessionid"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

This template adds the sessionid, which is passed as global parameter to the stylesheet, to the url. It's simple and reusable code and you can catch such things like links in javascript.

Another solution is a two step process. We set the attributes in a different namespace and in a second transformation step the sessionid is added:

<a url:href="http://www.foo.bar"/>

----

<xsl:template match="url:href">
  <!-- similar to the above one -->
</xsl:template>

Regards,

Joerg


Madhavi Thottempudi wrote:
Hi there!
I have realised that the file U have given me is actually for "encoding an url" but not for re-writing.
Sorry for any confusion. In Java, the method in the Servlet API for doing URL rewriting for session management is called encodeURL().
And I am looking for such session tracking/management in WAP devices.


My problem is, In wap devices it's creating a new session for every request, which means U get a new session id every time.
This makes the application to forget who the user is in his next request itself.


I read somewhere that I can use the hidden form fields to exchange the session ids between different requests. But there was not much info there,
so i din't get any clear idea on how I can implement it.
Any more ideas on this??


Any suggestions are greatly appreciated.
best regards,
Madhavi




At 17:18 28/11/2002 +0100, you wrote:


sorry, there is no such function.
But there is  a Java extension,
call (dependent to your product ) java from your stylesheet.
Xalan http://xml.apache.org/xalan-j/extensions.html#java-namespace and
Saxon
production
http://saxon.sourceforge.net/saxon6.5.2/extensibility.html
have a convenience approach.

HTH
mfh


>>> madhavi@xxxxxxxxxxxxxxx 28.11.2002 16.41 Uhr >>> Hi there! I am familiar with url rewriting in java using response.encodeURL(...) Can someone tell me how I can do that in xsl. I mean, is there a similar function to do that?? If not, what is the alternative that I can follow to maintain session tracking when cookies are disabled or not used (like WAP client). Any suggestions are greatly appreciated. best regards, Madhavi



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread