pawan
pawan

Reputation: 1

access hashmap in jsp

         <c:forEach var = "cart" items= "${cartx.items}"> 
            <tr bgcolor="${(i%2) ? "#EFF3FB" : "White" }">
                <td><c:out value = "${cart.key.tilte }"/></td>
                <td><c:out value = "${cart.key.price }"/></td>
                <c:set var = "price" value="${price}"></c:set>
                <c:set var="i" value = "${i+1 }"/>
            </tr>
         </c:forEach>

in this code snippet i want to access cartx which is a session variable and it contains list of book objects where book is a class.

i want to print the title and price of book which are the members of book class.

Upvotes: 0

Views: 1489

Answers (1)

Bozho
Bozho

Reputation: 597432

Maps are accessed in JSTL like that: ${map[key]}. (if key is an attribute as well)

Upvotes: 1

Related Questions