GeeCON Prague 2014*
The moose likes Servlets and the fly likes URL Rewriting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "URL Rewriting" Watch "URL Rewriting" New topic
Author

URL Rewriting

Parth Bhagat
Greenhorn

Joined: Mar 14, 2013
Posts: 7

Can any one explain the concept of URL Rewriting? I am having confusion with that.

Confusion is:
1.) URL Rewriting is used for Session tracking, by sending parameters/values to the URL as with get request.
2.) URL Rewriting is used for SEO, to make URL readable & easy to remember.

Can any one brief about the concept itself?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61301
    
  66

URL Rewriting


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42030
    
  64
That Wikipedia article covers only half of it, namely the #2 of Parth's question. That's the part where the external URL that the user (or a search engine) sees is different from the internal URL that the web app actually handles.

The first part is about changing a URL that is generated in the web app *before* it is sent out. Thus the altered URL is the same externally and internally. The only difference is the addition of the session cookie, though, which the servlet container handles, and not the web app code.


Ping & DNS - my free Android networking tools app
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Welcome to Javaranch Parth

URL rewriting is basically changing/ modifying the URL from what it should have been to something that either helps to maintain session (like when cookies are disabled) and other things like adding security, SEO, etc.
So lets say my original URL for a successful admin login page was http://foo.bar/admin I would rewrite it to http://foo.bar/admin?authkey=blahblahblah&session_token=blahblahblah.
Now both the above URLs server the same page and purpose. The latter one adds up two query string params to avoid cookies but still have some sort of authentication data in the request.
You can try disabling cookies in your browser to check out the difference in the URLs for most sites that use this approach, you will likely notice the jsessionid being appended at the end of the URL when you disable cookies. Although not all sites work can work that way.

Hope this helps.


SCJP, SCWCD.
|Asking Good Questions|
Parth Bhagat
Greenhorn

Joined: Mar 14, 2013
Posts: 7

Thank you all for your valuable reply.

Here is what I understood from these replies.
1.) For SEO purpose: It is done with the help of Rewrite Engine running on Web server.
2.) Session Tracking: In case when Browser Cookie is disable, using encodeURL method of HttpServletResponse instance session can be tracked for current transaction to the application.

Session tracking with URL Rewriting.


Please correct me if I am wrong at any point.

Thanks again for your responses.
 
GeeCON Prague 2014
 
subject: URL Rewriting