File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes URL-rewriting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "URL-rewriting" Watch "URL-rewriting" New topic


Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 224
I have confusion in understanding URL re-writing.Please check it is correct or not?

Http protocol is stateless protocol.Server not able identify the clients.So cookies are use as meduim by the server to share session id from client to server.
The main goal is to establish session between client and server.

suppose client is not accepting cookies.assume that user is sending first request by clicking on the link "click me" to server.

Q1) what are the steps the container will do?

1) Container will create unique session id for a client and suff session id in cookie and will send back to the client.
2) Now client is not accepting cookies: Now how container will come to know that client is not accepting cookies?
3) At time server send his first response to the client it tries both cookie as well as url re-writing(Assume url encoded)
4) At client side[browser] is not able add session to the cookie that client received. Session id is appended at the end of URL (Because of reponse.encodeURL).
5) Now herafter server starts using url -rewriting.

Q2)Please let me know if there are any steps missing in between?

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Step 3 is crucial - the server tries both cookies and URL rewriting. By the time the second client request comes in, there are two possibilities:
a) it contains a cookie - the server can henceforth use the cookie, and doesn't need to perform URL rewriting
b) it does not contain a cookie - the server must continue to use URL rewriting, since cookies are not used by the client
I agree. Here's the link:
subject: URL-rewriting
It's not a secret anymore!