in my cart page i show my product using an enhance for loop and therefore all input fields have same name as example -
<input type="hidden" value="<%= tcart.getIdtcart() %>" name="tcartid">
<input type="number" class="form-control" id="cartqty" value="<%= tcart.getQty()%>" min="1" max="<%= tcart.getProduct().getQty()%>" name="cartqty">
this run twice if there are two products in the cart. now my problem is when someone update the cart i send my form data into servlet in GET POST and it shows like this
http://localhost:8084/boodybuilding/updatecart?tcartid=98&cartqty=10&tcartid=99&cartqty=5
i used getParameterValues
to get values
String[] id = request.getParameterValues("tcartid");
String[] qty = request.getParameterValues("cartqty");
but what i want to do is i want to update my cart table using first index of id array with the value of first index of qty array, second ID with the second qty, and so on.