• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL Rewriting

 
Ashu Jain
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am slightly confused about URL rewriting.

Correct me if i am wrong -

My servlet creates html response that has something like this -

...
out.println("<html><body>");
out.println("<a href=\"" + response.encodeURL("/BeerTest.do") + "\">Click me</a>");
out.println("</body></html> ;
...

Say if i have three href links in my response then Do i need to encodeURL on all links in resonse html. something like this

...
out.println("<html><body>");
out.println("<br><a href=\"" + response.encodeURL("/BeerTest.do") + "\">Click me</a>");
out.println("<br><a href=\"" + response.encodeURL("/BeerXYZ.do") + "\">Click me</a>");
out.println("<br><a href=\"" + response.encodeURL("/BeerLMN.do") + "\">Click me</a>");
out.println("</body></html> ;
...


Please help
 
Vishal Chugh
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes
 
Ashu Jain
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will i get any error if do something like below. Encode only one URL and leave rest.

...
out.println("<html><body>");
out.println("<br><a href=\"" + response.encodeURL("/BeerTest.do") + "\">Click me</a>");
out.println("<br><a href=\BeerXYZ.do") + "\">Click me</a>");
out.println("<br><a href=\BeerLMN.do") + "\">Click me</a>");
out.println("</body></html> ;
...
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's easy to test, isn't it? But before you do that, try to answer it yourself - what do you think will happen if you click on the "BeerTest" link? What do you think will happen if you click on the "BeerXYZ" link?
 
Vishal Chugh
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No error , but in this case , 2nd and 3rd urls wont be appended with session ids and henceforth if the user clicked 2nd and 3rd option , we will never get session ids back for session mangmnt (given cookies are disabled ), so no session managent in that case.

If he clicked 1st option then it would be fine only then we would be able to do session management .
 
Ashu Jain
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks . Got it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic