Liz,

You might have to create another servlet to handle submits for both buttons.
The new servlet, will act as a controller and depending on which button is
clicked send the input to the correct servlet via RequestDispatcher.

For this to work your buttons must have the same name and both be submit
buttons.  Like the following.

<INPUT TYPE="submit" name="action" VALUE="buttonA">
<INPUT TYPE="submit" name="action" VALUE="buttonB">

Hope this helps!

Mike

-----Original Message-----
From: Liz Stanley [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 17, 2000 3:05 PM
To: [EMAIL PROTECTED]
Subject: question about how to use one form to submit to more than one
servlet


Hi,

I have an HTML form on a JSP which has the user select one or more items
using checkboxes. I have two buttons, say ButtonA and ButtonB. If the user
clicks ButtonA, I want to post to ServletA. If the user clicks ButtonB, I
want to post to ServletB.

The problem is, I have to specify the form action before knowing which
button the user will click. I've tried a couple of things that haven't
worked. One is using something like this for ButtonB (with the form action
being ServletA):

<INPUT Type=BUTTON name=buttonB value="buttonB"
onClick="JavaScript:location.href='/ServletB;'">

And the result is that no parameters (namely, the selected checkbox items)
are sent to ServletB.

The other thing I've tried is making ButtonB's input type SUBMIT, so it
submits to ServletA, but using the RequestDispatcher to forward on to
ServletB. What winds up happening here is that it does go to ServletB, but
actually continues back onto ServletA (I assume because that's the form
action.)

Any ideas?

thanks,

Liz Stanley
[EMAIL PROTECTED]
http://www.gymell.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to