This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes Multiple forms in Struts 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 » Frameworks » Struts
Bookmark "Multiple forms in Struts" Watch "Multiple forms in Struts" New topic

Multiple forms in Struts

Matthew Anderson

Joined: Jul 03, 2007
Posts: 9

I have a simple Struts app that's connected to a DB. I can search for an "employee" and now I want to add the functionality to add an employee, so I have two buttons in a JSP page. When I come to the Action/controller page, how can I know which button that has been pressed, i.e, which form that is populated? Can I set a variable in the JSP page, or what kind of info can I retrieve from the JSP page.

rahul khanna
Ranch Hand

Joined: Sep 14, 2005
Posts: 48
Rather than having buttons If you can have two hyperlinks that would solve the issue as you can call different actions..

If you have two buttons ..I am not sure .. but try enclosing them in two different forms within the same jsp..
Matthew Anderson

Joined: Jul 03, 2007
Posts: 9
I found this solution:

[ July 04, 2007: Message edited by: Code Exception ]
Ranjit Gopinathan
Ranch Hand

Joined: Jul 03, 2007
Posts: 46
Why dont you have a look at LookUpDispatchAction or DispatchAction.

I believe, that will solve your problem.
I agree. Here's the link:
subject: Multiple forms in Struts
It's not a secret anymore!