Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JSP and the fly likes dynamic form processing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "dynamic form processing" Watch "dynamic form processing" New topic

dynamic form processing

Dave Kinkead

Joined: Feb 22, 2003
Posts: 13
I want to be able to process form data dynamically based on what selection a user makes but am unsure of whih approach to take.
Basically, I want to have a form with 2 or 3 submit options. On submit, the form data is forwarded to the appropriate servlet depending on which submit button was clicked.
How would I do this - can I add some variable to the <form action="/servlet/???"> tag or is it possible to have the individual button forward the form data to a location based on the button's value?
Thanks in advance
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63873

Dave, either approach is viable.
If the server-side form processing is similar for the various situations, I think it'd be best to set a hidden parameter on the form that the servlet (or whatever's doing the form processing) can use to adjust the processing accordingly.
If the processing will be different for each case, you can modify the action attribute of the form to specify completely different servlets.
Which approach you take depends upon what makes the most sense for your app.
In either case, this is purely an HTML/Javascript operation, so we might want to move this dicussion here.

[Asking smart questions] [About Bear] [Books by Bear]
Raghunandhan Ramanujam

Joined: Jun 23, 2003
Posts: 10
Using the button's value seems to be a cleaner option
I agree. Here's the link:
subject: dynamic form processing
It's not a secret anymore!