Read data from HashMap using JSTL tag in JSP without using for each or for loop

Ankur Mukherjee picture Ankur Mukherjee · Mar 22, 2011 · Viewed 45.9k times · Source

I want to read data from a hash map in JSP, but without the use of JSTL <c:forEach> or a for loop. How can I do this?

Answer

BalusC picture BalusC · Mar 22, 2011

You need to know the keys beforehand.

${map.key}

The above gets the value of map.get("key").


Or if the key contains dots

${map['key.with.dots']}

This gets the value of map.get("key.with.dots").


Or if it's a dynamic key

${map[dynamicKey]}

This gets the value of map.get(dynamicKey).