This is perhaps a relatively simple thing to do but for some reason I don't seem to get it right.
How does one get an element from an arrayList in jstl based on an index.
In pure java, lets say I have this arralist
ArrayList< String > colors = new ArrayList< String >();
colors.add("red");
colors.add("orange");
colors.add("yellow");
colors.add("green");
colors.add("blue");
if I do System.out.println(colors.get(1));
I get the first color from the arrayList based
on the index I supplied which happens to be red
.
Wondering how to achieve that in jstl. I played with the foreach tag in jstl but did not quite get it right.
<c:forEach items="colors" var="element">
<c:out value="${element.get(1)}"/>
</c:forEach>