Reputation: 85546
I would like to use a JSP variable to access the elements of a Map in JSP, but I can't make it work. Here is what I tried:
<p>1. ${backups["2011-06-09_web05"]}</p>
<p>2. <c:set var="key" value="2011-06-09_web05"/> ${backups[$key]}</p>
I thought the two to be equivalent, but the first expression prints the value contained in the index specified, while the second doesn't print anything.
What is the right syntax? Thank you!
Upvotes: 0
Views: 2748
Reputation: 1109874
Remove the $
prefix. It is invalid. You probably had PHP in mind.
<p>2. <c:set var="key" value="2011-06-09_web05"/> ${backups[key]}</p>
Upvotes: 1