• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

setHeader

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are setting the response Header.But the getHeader method is in the HttpServletRequest Object.

How to get the Header Value (which has been set using response.setHeader method )
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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 ]
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
raja ram,

by not using punctuation you're making it very hard to understand your post. Please go back and edit your post accordingly.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Any updates on this?

Thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.)
 
deepa raj
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic