This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
buttons may be different but the button with SUBMIT type within a form will be considered for method (GET or POST). all other u can write as u wish. do not forget that they it should be in <FORM> </FORM> tag
Hareesh Ram Chanchali
SCJP 5.0, IBM Certified Solution Designer
The one that's not null is the one that was pressed.
The other approach, which I like less, is to give all the buttons the same name and read the value of the button.
I like this less because the value of a button is the text that the user sees. It's part of the view and shouldn't be used to govern the controller.
No matter what value you give to your buttons, inevitably, either a pony tailed web designer or a pointy haired boss will HAVE to change it. If the text is 'Enter' they will need to change it to 'Saved'. It may also need to be internationalized. In any case, when the text is changed, your servlet will break.
For this reason I prefer to test the name of the button not the value.
Another gotcha, if the user fills out the form and pressed the "Enter" key on the keyboard, the browser will pick the first submit button with both a name and a value and send that as the button that has been pressed.