Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get specific cookie?

 
Rob Deer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all the examples i've seen to get cookies is to use getKookies, store them into an array and loop through'em . is there a way to get a specific cookie like id:20 in one step?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ester,
Welcome to JavaRanch!

Yes, you need to loop through the cookie array. If you somehow knew the index of the cookie in the array you could go right to it. However, the cookies are not in any particular order. So you need to loop through each one to get the cookie name and see if it is the one you are interested in.
 
Sumitro Palit
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JSP 2.0 you can use EL to achieve this.
The syntax is ${wookie.wookiename}.
So, if your wookie name is id and stores a value 20,
${wookie.id} will output 20.

Please replace "w" in all "wookie"s with 'c'
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic