The Java EE 5 Tutorial

Dynamic Attribute Example

The following code implements the tag discussed in Dynamic Attributes. An arbitrary number of attributes whose values are colors are stored in a Map named by the dynamic-attributes attribute of the tag directive. The JSTL forEach tag is used to iterate through the Map and the attribute keys and colored attribute values are printed in a bulleted list.

<%@ tag dynamic-attributes="colorMap"%>
<c:forEach var="color" begin="0" items="${colorMap}">
    <li>${color.key} =
         <font color="${color.value}">${color.value}</font></li>