0

I have made a Cart where I need to print the specific order line number. I'm currently printing all the orders in a forEach and with my ${requestScope.cartsize} it is naturally giving my the full size. How do I use my forEach and only print the indexnumber in the array so it will naturally have 1, 2, 3, 4 and not 3, 3, 3, 3 if it shows all orders?

        Cart is having:<br>
        <c:forEach var="item" items="${sessionScope.cart.cupcakeList}">
            Bottom: ${item.bottom.name} Topping: ${item.top.name} Price ${item.quantity} Order line number: ${requestScope.cartsize}
            <form action="addtocart"><button name="removeFromCart" value="${requestScope.cartsize}"type="submit">Fjern fra kurv</button></form><br>
        </c:forEach> ```
Narj
  • 39
  • 5
  • 1
    not sure what you expect with requestScope.carsize (it will print the cartsize based on your requestScope variable which assuming it's correct, it will correspond to a rather "static" value of sessionScope.cart.cupcakeList.size()) If you want to get the iteration index, you might want to take a look at https://stackoverflow.com/a/18826043/3252327 – user3252327 Nov 15 '22 at 23:39
  • Thank you, loop index was exactly what I needed! – Narj Nov 15 '22 at 23:47

0 Answers0