Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Servlets
Refreshing Cookie
Jigar Naik
Ranch Hand
Posts: 763
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have created a small application for setting and getting cookie.
String name1 = req.getParameter("param1"); String name2 = req.getParameter("param2"); String name3 = req.getParameter("param3"); Cookie cookie1 = new Cookie("param1",name1); Cookie cookie2 = new Cookie("param2",name2); Cookie cookie3 = new Cookie("param3",name3); resp.addCookie(cookie1); resp.addCookie(cookie2); resp.addCookie(cookie3); Cookie[] c = req.getKookies(); for(int i=0;i<c.length - 1;i++){ Cookie cookie = c[i]; System.out.println("getName() : " + cookie.getName() + ", getValue() : " + cookie.getValue()); } System.out.println("param1 : " + name1); System.out.println("param2 : " + name2); System.out.println("param3 : " + name3); System.out.println("============================================");
Output at 1st run :
12:22:59,070 INFO [STDOUT] param1 : p1 12:22:59,102 INFO [STDOUT] param2 : p2 12:22:59,102 INFO [STDOUT] param3 : p3 12:22:59,102 INFO [STDOUT] ============================================
Output at 2nd run
12:24:27,779 INFO [STDOUT] getName() : param1, getValue() : p1 12:24:27,779 INFO [STDOUT] getName() : param2, getValue() : p2 12:24:27,779 INFO [STDOUT] getName() : param3, getValue() : p3 12:24:27,779 INFO [STDOUT] param1 : pp1 12:24:27,779 INFO [STDOUT] param2 : pp2 12:24:27,779 INFO [STDOUT] param3 : pp3 12:24:27,779 INFO [STDOUT] ============================================
my question is output at 2nd run should be following
12:24:27,779 INFO [STDOUT] getName() : param1, getValue() : p11 12:24:27,779 INFO [STDOUT] getName() : param2, getValue() : p12 12:24:27,779 INFO [STDOUT] getName() : param3, getValue() : p13 12:24:27,779 INFO [STDOUT] param1 : pp1 12:24:27,779 INFO [STDOUT] param2 : pp2 12:24:27,779 INFO [STDOUT] param3 : pp3 12:24:27,779 INFO [STDOUT] ============================================
Jigar Naik
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Why do you think it should be p11,p12,p13 ?
[My Blog]
All roads lead to JavaRanch
Jigar Naik
Ranch Hand
Posts: 763
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
because, first is set the parameter value and than i get the parameter value. so i should be getting those value which i had set last time.
Jigar Naik
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I don't see anywhere that you're setting "p11".
param1 = p1, not p11
[My Blog]
All roads lead to JavaRanch
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
inverse=true in many-to-many doubt
Cookie Help
Calling Stored Procedure thru JPA
response.addCookie is not working
Setting Cookie
More...