The attribute of the name and value of the submit button will also be SENT if you click this button to submit the form. In the servlet, you can check if you can get these parameters to find out which button is pressed.
For example, suppose you have two buttons: one for updating and one for deleting
<input type="submit" name="update" value="Update Button"> <input type="submit" name="delete" value="Delete Button">
If you click the update button, it will display the update=Update Button variable update=Update Button If you click the delete button, it will display the delete=Delete Button variable delete=Delete Button
Then to the servlet:
if (request.getParameter("update") != null) { //update button is clicked //Do the update action or forward the request to the servlet to do update action } else if (request.getParameter("delete") != null) { //delete button is clicked //Do the delete action or forward the request to the servlet to do delete action }
source share