JSTL to iterate map

SvetaBeloglaz

New Member
am using JSTL to get values from the bean class . The values am getting from the bean class will be of java.util.Map . am success in getting the values by the below code : \[code\]<c:forEach items="${bean.map}" var="item"> <c:out value="http://stackoverflow.com/questions/14481848/${item.key}"/> = <c:out value="http://stackoverflow.com/questions/14481848/${item.value}"/><br/> </c:forEach> \[/code\]After getting the key-value pair , i need to create a table with 4 rows and 7 columns. Map : \[code\]map.put(2, true);map.put(18, true);\[/code\]The key in the map will be of from 1-28 and the values will be TRUE or FALSE .If the key is 2 and the value is TRUE , ineed to place a check mark in (1,2) of the table ie: 1st row 2nd column . Likewise , if the key is 18 , need to place a check mark in (3,4) of the table .\[code\] <table border="1" width="100%"> <tr> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> <th>6</th> <th>7</th> </tr> <c:forEach items="${bean.map}" var="item" > <tr> <td><c:out value="http://stackoverflow.com/questions/14481848/${item.value}"/></td> </tr> </c:forEach> </table>\[/code\]I dont know how to proceed further , since i am restricted to use only JSTL and am new to JSTL . Am not allowed to use javascriptor jquery which makes the life easy . Kindly give me some suggestion to proceed further . Any help will be appreciable .
 
Back
Top