Sending fields to servlets
I am trying to create an auction website. I have a table that contains the item data. What I want is, when a user clicks on "Buy item", to get the item id of this specific item, so that I can tell it is a bought item. Here is the code from the jsp.
Code:
int itemnumber = ItemDAO.getitemRowcount();
for(int i = 0; i < itemnumber; i++) {
ItemBean bean = new ItemBean();
bean.setItemid(i+1);
// I want to have this id on the server side, when "Buy item" is pressed, and the jsp is sent to BuyitemServlet
bean= ItemDAO.getItems(bean);
String itemtitle = bean.getItemTitle();
String itemdescription = bean.getItemDescription();
double itemprice = bean.getPrice();%>
<tr>
<td> Image </td>
<td> <%= itemtitle %> </td>
<td> <%= itemdescription%> </td>
<td> <%=itemprice%> </td>
<td>
<form action ="BuyItemServlet" method = "post" >
<input type = "submit" value = "Buy item">
</td>
</tr>
</form>
<%
}