File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get the button value from request.getParameterValues()

 
H Johan Lekberg
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp page that contains a form.
In the form i have several fields and buttons.
I am able to get the values from the fields but now I also want to know witch button that was pressed.
How do I do that?
/Jle
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that the buttons are of type "submit", the easiest way is to just give them all the same name with differing values as in:

You will get a single request parameter named "theButton" which will have the value of the clicked button as its value.
However, since the values are visible (they serve as the caption of the button), you may not be able to have unique values (if all the buttons need to be captioned "OK", for example). In this case you could use unique names for each of the buttons and look through the list of request parameters to see which one got submitted.
If your buttons are not submit buttons, you might have to resort to a small bit of JavaScript.
hth,
bear
[ March 17, 2003: Message edited by: Bear Bibeault ]
 
Marty Hall
Author
Ranch Hand
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am able to get the values from the fields but now I also want to know witch button that was pressed.


Cheers-
- Marty
 
H Johan Lekberg
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, it helped!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic