• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL & Cookies

 
Mark Beavis
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there -

I'm trying to write some JSTL to print out all the cookies in the current request.

Here is my code:


and I get an exception:
Unable to find a value for "name" in object of class "java.util.HashMap$Entry" using operator "."


I also tried the [] operator and nothing at all was printed.

Can anyone help.

Thanks
Mark
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${cookie} is a Map whose key is the cookie name, and whose value is the Cookie itself.
Iterating through a Map returns Map.Entry elements, so in your example, currentCookie is a Map.Entry.



1. currentCookie.key calls getKey() on Map.Entry
2. currentCookie.value calls getValue() on Map.Entry. It returns a Cookie.
3. currentCookie.value.value calles getValue() on Cookie. It returns a String.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!