• 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

Cookies associated to a Session

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 36
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 171
Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic