File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to reference a hash map value with a JSP variable as its key?

 
Stan Lederer
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a hash map entry in a JSP which I can display fine as ${current.collectionCode}.

I have a second hash map, ${collectionUrls}, from which I can extract, as an example, ${collectionUrls['XYZ']}

If ${current.collectionCode} = XYZ, how can I get ${collectionUrls[${current.collectionCode}]}?

I'm stumped.

Thanks.
 
Paul Clapham
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not

There's too much markup there. You just need ${} to indicate that the contents is an EL expression, no more. So
 
Stan Lederer
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Not

There's too much markup there. You just need ${} to indicate that the contents is an EL expression, no more. So

Paul, that worked beautifully. Thank you.

Now, would you help me to understand why I don't need ${} around the variable when it's used in this context but I do need it when the variable is used by itself? Is there a rule that you should only ever use one set of ${} in an expression and anything inside of it that doesn't look like a literal is assumed to be a variable?
 
Paul Clapham
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like I said. You put ${} around an EL expression. Not in it, but around it. That's all. It doesn't matter whether the expression is a single variable or a complex calculation.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${} is not a "fetch" operator. It's merely a delimiter around an entire EL expression.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic