Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL-rewriting & encodeURL()

 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • 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 .
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • 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
  • 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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic