Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

URL-rewriting & encodeURL()

 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
For robust session tracking, all URLs emitted by a servlet should be run through encodeURL() of HttpServletResponse()
method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

I have two questions :
- Does encodeURL() , along wid including session-tracking token , also converts strings to urlencoded-form ??
( I mean to say , along wid session-tracking, does it also do da same job as java.net.URLEncoder.encode()? )
- We are explicitly required to call encodeURL() on all URLs in our servlet's response
Wouldnt it have been better if some sort of 'filter' internally being used by web-component on final-response object to include URL-rewriting info ?
Tht wuld have made session-mgmt transparent , more in dat sense.
( Infact some func , like of doNotEncodeURL() culd have been provided , to give developer choice of avoiding session-mgmt at his will for diff URLs , and much less no of uses of this method wuld have been required )
------------------
Gagan (/^_^\) SCJP2
Die-hard JavaMonk -- little Java a day , keeps u going .
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gagan Indus:
- Does encodeURL() , along wid including session-tracking token , also converts strings to urlencoded-form ??

No. Note that the Javadoc states that the URL is returned unchanged if sessions can be tracked by other means.

Wouldnt it have been better if some sort of 'filter' internally being used by web-component on final-response object to include URL-rewriting info ?

Well volunteered; with Servlet 2.3 filters this should be a doddle provided you don't get too fancy about recognising JavaScript-driven URLs. It would be nice and convenient for low-volume purposes. For high-volume sites, of course, the overhead of parsing the HTTP response for URLs would be prohibitive
- Peter
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanky Peter
about encodeURL() :
the name confused me into thinking dat . But now i am sure about it. I think , i shld read API-doc wid more concentration
about dat 'filter' thing :
Oh i am happy , dat i am thinking on da right track . At least i have strated getting lill hold of this whole web-architecture things . 10x for ur informed answer.
------------------
Gagan (/^_^\) SCJP2
Die-hard JavaMonk -- little Java a day , keeps u going .
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic