jQuery in Action, 2nd edition*
The moose likes JSP and the fly likes URLrewriting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "URLrewriting" Watch "URLrewriting" New topic
Author

URLrewriting

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
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

Joined: Aug 17, 2005
Posts: 69
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

Joined: Jul 04, 2004
Posts: 979
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

Joined: Jan 24, 2005
Posts: 489


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

Joined: Jul 04, 2004
Posts: 979
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

Joined: Jul 06, 2005
Posts: 1016
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

Joined: Jul 04, 2004
Posts: 979
Thanks Stefan!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLrewriting