• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed with map

 
P Betta
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 maps and I need to loop through the first map and for each key that I get in the first map I need to find if the key exists in the second map. How do I use map.ContainsKey() and map.get() using JSTL? If the key is found in the second map, I need to display the value.

Any insight on this is appreciated.

Thanks in advance.

PB
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This actually has less to do with the JSTL than with the EL.

In the EL you cannot call any random method. So a call to a method like containsKey() is not possible. However, you can perform other actions that will yeild similar results.

In the EL, you would do the equivalent of a get() by simply naming the property. So if, for example, you wanted to fetch the mapped value of key 'abc' from a map in scoped variable 'xyz', you would use:



If the key were not hard-coded and was instead in a scoped variable named 'def':



To test whether the key in scoped variable 'def' is defined, you could use:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic