This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Setting Multiple values in cookie before the response is committed Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Setting Multiple values in cookie before the response is committed" Watch "Setting Multiple values in cookie before the response is committed" New topic
Author

Setting Multiple values in cookie before the response is committed

Bharathkvr Kumar
Greenhorn

Joined: Oct 15, 2009
Posts: 2
Hi,

I need to set multiple values for a cookie with same name.

CookieName Value

User Name -- Xyz
Address -- abc
phone -- 123.

I have a method which sets one value at a time. (user --->name--->xyz) and adds it to the response. I call this method 3 times at 3 different places, for the same request before the response is committed. So,I have only the last set property .

We can have all the three values if i do response.addCookie for the same cookieName only once.But is there any other way so that response.addCookie can be called 3 times for the same request.

Also,

Once i call response.addCookie, is it possible to retrieve the set value before the response is committed.

Thanks.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35249
    
    7
Welcome to JavaRanch.

If you want to have 3 cookies, then you need to give them 3 different names. You can only have a single cookie with any particular name.

Or you could use a single cookie that has all the information in an simple format like "name=xyz;address=abc;phone=123"; just make sure that the delimiter (";" in this case) isn't part of the data.

is it possible to retrieve the set value before the response is committed.

No


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Setting Multiple values in cookie before the response is committed
 
Similar Threads
change cookie value
Why isn't my cookie being set?
Using a method to retrieve a cookie
problem in cookie
SESSION TRACKING.