File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cookies associated to a Session

 
rags singh
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am reading Head First Servlets and JSP and in the topic dealing with Cookies it says that cookies can be retrieved from a client request using the

My question is if cookie is used to identify a single client , how can a servlet get a cookie array from a request (from a single client) ie how can a client send multiple cookies and under which scenario ?

Thanks,
ragini
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rags singh wrote:how can a servlet get a cookie array a request from a single client ie how can a client send multiple cookies and under which scenario ?

Sorry, but something seems to have gone wonky with that sentence and I'm not sure what it is that you are asking.
 
Ram Narayan.M
Ranch Hand
Posts: 247
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Server can send many cookies in response to the client.

In return, cookie being sent in request to the server is based on "path" and "domain" set in cookie while sending in response...

If the Cookie path is set to particular context path "/webApp" and domain "www.site.com"

Then, cookies will be sent along with request with URL path of the resource under "www.site.com/webApp/" from the client.

If its "/" and domain "www.site.com",

Cookies will be sent to any web application under "www.site.com" domain.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As mentioned, the server can send multiple cookies, and when the client sends a request, all the associated cookies are sent in the cookie array. Then you can iterate this array to get a specific cookie.
 
Ankush Kaundal
Ranch Hand
Posts: 36
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes there can be many cookies sent by the server and you can even create your own cookies and get it added via response.
 
Kumaravadivel Subramani
Ranch Hand
Posts: 171
Java Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not always single cookie or multiple cookies which can be send with request by server, but you can have one or more cookies in the request.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic