View Feed
group-icon
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12764 Members
Join this group to post and comment.
greatcoder
greatcoder • Apr 1, 2012

URL Rewriting In JSP & Advantages

Hello Experts,

I have heard a lot about URL rewriting. Can u plz tell me
1) How to implement URL rewriting in JSP
2)WHat are the advantages of URL rewriting?

Regards
GC
Ankita Katdare
Ankita Katdare • Apr 2, 2012
greatcoder Good question indeed. I have no knowledge about the implementation part. However, I too have read quite a bit about it.

URL rewriting can be termed as a way of supporting 'anonymous session tracking'.
Meaning to say, the local URLs can be loaded with additional information by modifying/rewriting them. This extra information is usually limited to a unique session ID. I think it must be a tiresome task to rewrite the URLs.

The real benefit, as they say, is "search engine optimization" or SEO for budding OR NEW websites. Substantially old websites do not want to indulge in this, because that might not reflect very well in their search engine rankings, because the spiders will have to be made known about your new page locations.

Hence, URL rewriting will work only for the websites whose pages are not already listed on Google, Yahoo and the likes.
IDs and Anonymous Session Tracking? New to that here... 😛

Anyways, the main use is like what you said is SEO. Another thing is, it is better to remember URLs like facebook.com/crazyengineers other than having facebook.com/?page_id=10000000456788 right? That's another main use... 😀
Good question and good answers.

So what facebook,twitter profile page URLs' uses is URL rewriting, right?

Now I want to know about implementation part. Anyone here can hint about it?
Sada
Good question and good answers.

So what facebook,twitter profile page URLs' uses is URL rewriting, right?

Now I want to know about implementation part. Anyone here can hint about it?
Why are you going to that extent? Simple! Even our CrazyEngineers Forum uses URL Rewriting. There is no URL like https://www.crazyengineers.com/community/threads/url-rewriting-in-jsp-advantages.53260, but actually the URL is https://www.crazyengineers.com/community/index.php?threadid=53260 (or something similar, purposely didn't reveal the original one). It can be done only by the server.

In CE's case, it is the Apache Server and it uses mod_rewrite.
In Windows, it would be IIS 7 or later, with the URL Rewrite Module installed.
In case of JSP, it is web.xml, where you give the routes.
In case of Rails, it is Rake Routes... 😁
sookie
sookie • Apr 9, 2012
You can use "response.encodeURL(String url)" in JSP to apply URL rewriting.

And regarding more info about "URL rewriting" read this article https://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/ . Good one!
sookie
You can use "response.encodeURL(String url)" in JSP to apply URL rewriting.

And regarding more info about "URL rewriting" read this article https://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/ . Good one!
Buddy, response.encodeURL has lots of bugs, and it won't work if output has been buffered... 😔
ysr shk
ysr shk • Apr 24, 2012
URL rewriting is sometimes used to hide the attribute values to be displayed in the address bar.
Suppose I have 2 attributes,which I am sending from a html page.
then after that page name that are added,if I had been use method GET.
like, xyz.com/abc.html?fist_attribute=something&second_attribute=something.

Sometimes in JSP it is not supported to use POST method so we has to use GET.
And it is not secure that your user name or password to be displayed in URL,it's break the privacy of that user.
So we have to encode that URL by rewriting it.

You can use the method as told by sookie

URL rewriting is same as DNS concept.
In DNS,we automatically replace the Name to corresponding IP or vice-versa.

Share this content on your social channels -