Liz:
How about having a "DecidingServlet" in the action url of your JSP form. (Make sure
the method is post). In DecidingServlet, do a getParameter("ButtonA") and
getParameter(ButtonB") and use a RequestDispatcher in the following way:
if (req.getParameter("ButtonA") != null){
Code to forward to servlet A with ReqDispatcher;
}
else if (req.getParameter("ButtonB") != null) {
Code to forward to servlet B with ReqDispatcher;
}
//IMPORTANT: Do not add any code here in DecidingServlet! If you do, this part of the
code wil in fact be executed after the forward..
Hope this helps!
Geeta
Liz Stanley wrote:
> 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