Is it possible to get the "row" index from an arraylist using JSTL?
<c:forEach items="${searchResults}" var="contact">
<div style="padding: 5px;">
${contact.firstName} ${contact.lastName}
<br>
${contact.primaryPhone}
</div>
</c:forEach>
My intention is to set a hyperlink that contains each items ID on each row so the user can click and display a popup, or another page and easily retrieve just the single object from the arraylist without going back to the database and setting another session object etc.
Use varStatus
attribute.
<c:forEach items="${searchResults}" var="contact" varStatus="loop">
<div style="padding: 5px;">
${loop.index} -
${contact.firstName} ${contact.lastName}
<br>
${contact.primaryPhone}
</div>
</c:forEach>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With