Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending a session cookie in the response

 
Jose Esteban
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In page 231 of HFSJ you can read:
------------------------------------------
Sending a session cookie in the response
HttpSession session = request.getSession();

... everything else happens automatically.
...
You don't set the Cookie into the response (under the Set-Cookie header).
------------------------------------------

Since the getSession() method doesn't have any reference to the response, I don't understand how this method can set a cookie into the response.

Anybody has an explanation?
 
Ganeshji Marwaha
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will try to attempt this question.

The container is the one who provides the servlet with reference to request and response objects it creates. so, obviously the container will have a reference to the response object, until the response is completely written to the client. Then both request and response may be GC-ed.
 
Bassam Zahid
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is done by the container by "adding a header containing cookie object" in response object.

The container might do it this way:

Of course, the container has references to request / response and other objects.
 
Jose Esteban
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic