Falci
Falci

Reputation: 1873

How to do a foreach loop in a LinkedHashMap in JSP?

I do not have much experience with jsp. In java I can do, but it is not good to open a block <% %>

Upvotes: 1

Views: 5028

Answers (1)

kosa
kosa

Reputation: 66647

You can use JSTL foreach to iterate over the HashMap.

<c:forEach var="type" items="${yourMap}">
   Key is ${type.key}
   Value is ${type.value}
</c:forEach>

NOTE: If you are using Tomcat, you need to explicitly copy JSTL lib to classpath. With other servers I know of default comes with JSTL.

Upvotes: 8

Related Questions