• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URL rewriting

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello can anyone explain URL rewriting with a code example for maintaining session.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
URL rewriting is a fallback mechanism if the client rejects cookies which are the standard mechanism in force for session tracking.

You can encode a URL in your servlet using response.encodeURL() . Check the API dokumentation for more info on that.

As for JSPs, check c:url.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Session plays an important role in most web applications. Since HTTP protocol is stateless, the Server identifies the user via the JSESSIONID cookie created at the user end. Most users don't disable cookies in their browser. But when a user has disabled cookies in his browser, URL rewriting is the only by which we can exchange session Id between client and the server.URL rewriting is simple.
In URL rewriting technique we can see that the jsessionid will be appended to the hyperlinks in the web page.

In JSP use the c:url tag.
<a href=”<c:url value=’/Example.do’ />”>Click here</a>

IN Servlets use the encodeUrl()
Use the encodeURL() function of response object.
Example:
out.println(“<a href=\”” + response.encodeURL(“/Example.do”) + “\”>click here</a>”);

Final sample URL : (look at the jsessionid appended to the URL)
http://www.tester.com/Example.do;jsessionid=0CCB5C8DE517
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic