This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Cookies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Servlets
Bookmark "Cookies" Watch "Cookies" New topic


Usha KV

Joined: Jun 05, 2001
Posts: 4
Is it possible to create more than one cookie from a page. I tried doing so but it was overwriting the already existing one.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Yes, you can create more than one cookie per page, as long as the cookies have different names.


So much trouble in the world -- Bob Marley
Cynthia Yao
Ranch Hand

Joined: Nov 06, 2000
Posts: 92
cookies are just set of name and string value pair. You definitely can put more than one cookie, but you have to set it one by one in jsp. Here is some notes from netscape about cookie specs.
Multiple Set-Cookie headers can be issued in a single server response.
Instances of the same path and name will overwrite each other, with the latest instance taking precedence. Instances of the same path but different names will add additional mappings.
However there are limitations: 4 kilobytes per cookie, 20 cookies per server or domain.
Hope this answers your question
I agree. Here's the link:
subject: Cookies