Request and response (and their headers) have nothing to do with one another; it makes no sense to retrieve response headers (or set request headers) on the server. That's for the client (the browser) to do. [ August 20, 2008: Message edited by: Ulf Dittmer ]
Ok then we add the info in to response and read the info from the request the reason for this is. when the first request comes and say i call request.getSession() it attaches the session id in the response header even though session id is attached in the response we still call request.getSession() rather than response.getSession(); this is mainly because first request comes and once processed next request will not have any info about the first request. Ok fine in that case the first response was sent and for second request it will send second response which will also not have any info about the previous response is that correct? if correct then how this thing is working. Is it some thing like that server will maintain some state for every client that when you call response to perform add or set it will write in to this place and when we call request to retrive the info it will use some mechanism to identify which is the location where it has wrote the info and get that info for the request. in this way just by having mechanism of identifying the request and responses and corressponding location where it is storing the info it will process the request. Is this Correct?
Thanks [ August 21, 2008: Message edited by: raja ram ]
Joined: Mar 22, 2005
by not using punctuation you're making it very hard to understand your post. Please go back and edit your post accordingly.
Joined: Mar 02, 2008
Any updates on this?
Joined: Mar 22, 2005
Sessions are independent of individual requests and responses. They are identified by a session ID, which is set as a cookie by the first response after the session has been created. Each request coming in after that will include the session cookie. Thus, although the session state is kept on the server, the crucial information for associating a session to a request is done through the cookie (which is sent with each request).
(There's also another mechanism for transporting the session ID -called URL rewriting- for cases where cookies are not available.)
Joined: Jul 25, 2008
when the first request comes and say i call request.getSession() it attaches the session id in the response header even though session id is attached in the response we still call request.getSession() rather than response.getSession();
When you call the getSession() , server will create the session-id cookie and attaches that cookie to the response header.
After that , if the clent wants to continue the session , it should get the session-id cookie from the response header , it has to attach the same session-id to the Request Header.
So on the hole, Response header are being set for the clients like browser. Request Headers are from the client set by the client for Server to process the request.
[ UD: replaced CODE tags with QUOTE tags so that the layout isn't broken ] [ August 22, 2008: Message edited by: Ulf Dittmer ]