Is it possible to determine which submit button was used? I have a confirmation form with 2 submit buttons. The first would confirm the order, do some DB tasks, then redirect. The second, which is a Cancel button, will just redirect to the same page, without doing any DB tasks.
Is it possible in the servlet, preferably via the request object, to determine which submit button was used? I'd prefer not to be dependent on Javascript, as that is pretty simple, but will resort to it if the only possibility.
Thanks.
<button name="someName" value="someValue" type="submit">Submit</button>
<button name="otherName" value="otherValue" type="submit">Cancel</button>
You'll have someName=someValue
or otherName=otherValue
in your request data
Sure, just give each of your submit
buttons a name
attribute, and whichever one was clicked will appear in the submitted variables:
<input type="submit" name="doConfirm" value="Confirm" />
<input type="submit" name="doCancel" value="Cancel" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With