This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLrewriting

 
A Kumar
Ranch Hand
Posts: 980
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
For servlets...we have encodeURL for url rewriting...in case cookies are disbled at client side...

But how to do the same if only jsp's are involved...


Regards
 
Darren Edwards
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you have JSTL available within your JSP


Be aware that it will not encode GET parameters in the same way encodeURL does - you have to do the following
 
A Kumar
Ranch Hand
Posts: 980
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Darren,

Thanks for the response....
I wanted to know about the pre-JSTL days..How they used to do it?

Regards
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I wanted to know about the pre-JSTL days..How they used to do it?


You could very easily write a custom tag. Or else write in a scriptlet, the exact code that you would, if it were a Servlet (though it would undoubtedly clutter your jsp code)

ram.
 
A Kumar
Ranch Hand
Posts: 980
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the solution...was ....

writing the same code that would be there in servlet ...as in a scriptlet section of a jsp...

Is it so???
 
Stefan Evans
Bartender
Posts: 1640
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could do it with scriptlet expression
<a href="<%= response.encodeURL("/user/save.jsp") %>"> Save </a>

No it doesn't look nice. And people often forgot to do it.
Hence custom tags which take care of it for you ;-)
 
A Kumar
Ranch Hand
Posts: 980
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stefan!!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic