• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

encodeURL and encodeRedirectURL

 
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?
 
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.
 
Author
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.
 
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.
 
Ranch Hand
Posts: 598
3
jQuery Google App Engine Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was confused too ,you guys eliminated my doubt.

best regards,
omi
    Bookmark Topic Watch Topic
  • New Topic