This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Struts and the fly likes Multiple forms - one jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple forms - one jsp" Watch "Multiple forms - one jsp" New topic

Multiple forms - one jsp

M. Sigler

Joined: Oct 21, 2004
Posts: 2
I am having a dilemma on how to handle two forms on one jsp page. The first form is basically a header with a drop down list in it. I have a form bean and an action mapping for that. The second form is a display of users from the database again with its own form bean and action mapping. Ultimately if the user changes the information on the drop down list the report under it will change as well, but I am not sure how I can get the data from the drop down list into the second form.

If I try to retrieve anything in the second action form that has to do with the first then I get a null pointer exception.

Do I need to set something up in my struts-config.xml that allows them to talk to each other or do I need to do something totally different?

John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
Try using your action class to extend LookupDispatchAction instead of action, this class is made for multiple submit buttons. You can have one big form with two different submit buttons, it will call your class and jump to the appropriate execute method depending on which submit button was clicked. Sounds a little tricky but the struts API shows you exactly what you need to have in your action class to set this up, it's really quite easy
I agree. Here's the link:
subject: Multiple forms - one jsp