wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: http://www.mail-archive.com/struts-user@jakarta.apache.org/msg24165.html

[ 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.
jQuery in Action, 2nd edition
subject: Multiple forms in Struts
Similar Threads
Struts handling multiple arraylists
Employee Application developed in Struts
iterating tables
How to set a radio button selected from a JSP page, with the help of values extracted from database?
How Struts will identify Class (with get / set methods) associated with it