jstl collection size and last element

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<c:forEach items="${order.entries}" var="product"
									varStatus="loop">
							 ${product.product.name }
							 
								<!-- 	print comma if there is no only one products or it is the last element -->
									<c:if test="${fn:length(order.entries) gt 1 && !loop.last}">, 
							 </c:if>
								</c:forEach>

Leave a Reply

Your email address will not be published. Required fields are marked *