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

encodeURL and encodeRedirectURL

 
Chatura Dilan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I wonder what's the difference between encodeURL(String) method and encodeRedirectURL(String), because both of them act as same with the sendRedirect(String) method. that means

sendRedirect(encodeURL(String))

sendRedirect(encodeRedirectURL(String))

are same.

i don't understand what's the special in encodeRedirectURL(String) method?
 
Bastin Gomez.H
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference lies in whether you want to use URL rewriting or not. If cookies are disabled, you cannot use cookies to maintain a session, every request to the server would be a fresh one. To overcome this situation, URL rewriting can be used. What URL rewriting does is, with every URL you send to the server, the sessionid will be appended with a semicolon separator like below.

http://localhost:8080/someservlet;jsessionid=sjkfhk83478397492....

All your urls have to rewritten using encodeURL & if it has to redirected, then encodeRedirectURL method has to be used for rewriting.
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All your urls have to rewritten using encodeURL & if it has to redirected, then encodeRedirectURL method has to be used for rewriting.
Exactly - the difference being that encodeURL always writes the session ID into the URL (if required e.g. because cookies are disabled), while encodeRedirectURL contains additional logic to determine if it is desirable to write the session ID in. It is a really bad idea to give foreign websites the session ID for example, since then they could impersonate your user's session. Hence encodeRedirectURL will only put the jsessionid on the URL if that URL lies within the current Web application, and not perform any rewriting otherwise.
 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PLease correct me if i am wrong?
From above two reply it is clear to me that it will rewrite the url and append session id. This happens when cookies are disabled.

encodeURL()

Q1)Another job perform by encodeURL--> Replacing non standardised characters
like spaces with '+' symbol.
 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was confused too ,you guys eliminated my doubt.

best regards,
omi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic