Don’t know a better title but here is what im trying to do.
I have the following form where which will display a list of books and after every book entry there is a remove button. The list can be any length. In order to get the book id I have set name="remove[${cartItem.bookId}]" but how do I get this value in a servlet? request.getParameter("remove") and request.getParameterValues("remove") returns null everytime.
<form method="post" action="removeBookFromCart">
<c:forEach var="cartItem" items="${sessionScope.cart.cartItems}">
<tr>
<td><c:out value="${cartItem.title}" /></td>
<td><input type="submit" name="remove[${cartItem.bookId}]" value="Remove"/></td>
</tr>
</c:forEach>
</form>
You have to use hidden parameters:
Let the submit button be just this way:
EDIT:
Yes, you have to create a form element for each book: