I am retrieving a list of image objects from database on a JSP page in a table format. I have to perform delete operation on an image for which I'll need the image id. Delete will be performed on click of an image button. How can I pass the id of the image clicked to the servlet in which I'm deleting the image from the database. Here is the code I'm trying :
<%
for (Image image : images)
{
double imageSizeInKB = image.getImageSize()/1000.0;
int imageId = image.getId();
%>
<tr>
<td><%=serialNumber%></td>
<td><%=image.getImageName()%></td>
<td><%=imageSizeInKB%></td>
<td><img src="data:image/jpg;base64,<%=image.getBase64Image() %>" width="200" height="200"/></td>
<td><img id="edit" width="40" height="40" src="Images/edit.png"/>
<form action="delete" method="post">
<input type="image" onClick= "<% session.setAttribute("imageId",image.getId()); %>" src="Images/delete.png" name="submit" width="40" height="40" alt="submit"/>
</form> </td>
</tr>
<%
serialNumber++;
}
%>