Stephen on Software aka SOS

June 3, 2009

Hashmaps and JSTL

Filed under: Programming — Tags: , — sljm @ 2:43 pm

Learnt a few things about how to use HashMaps in JSTL.

To access a hashmap with a key in JSTL.

${map.key} or ${map[key]}

If your key is from some other variable or you need to set the key dynamically

//Create a variable call keyName and set the value to something
<c:set var="keyName" value="${someObject.id}"/>
<c:out value="${map[keyName].id}/>

Blog at WordPress.com.