1

I'm hoping someone can give me a few pointers. I've tried a few iterations of accessing dynamic variables with JSTL, but I can't get it to work with cookie.

How can I use a dynamic variable to access the cookie name and have jstl expose the value?

<fmt:message key="my.app.cookieName" bundle="${secProps}" var="cookieNameFromProps"/>
${cookie.<cookieNameFromProps>.value}
  • My reputation is not high enough to answer the question so quickly: Figures... I post a question and then figure it out on my own shortly there after! Because cookie is a Map under the covers you can access it in the following manner I used this as a reference: http://stackoverflow.com/questions/5395308/read-data-from-hashmap-using-jstl-tag-in-jsp-without-using-for-each-or-for-loop – user3862422 Jul 21 '14 at 22:26

1 Answers1

0

Figures... I post a question and then figure it out on my own shortly there after!

Because cookie is a Map under the covers you can access it in the following manner

<fmt:message key="my.app.cookieName" bundle="${secProps}" var="cookieNameFromProps"/>
<c:out value="${cookie[cookieNameFromProps].value}"/> 

I used this as a reference: Read data from HashMap using JSTL tag in JSP without using for each or for loop

Community
  • 1
  • 1