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.
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.
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.