This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Multiple form with one action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Multiple form with one action" Watch "Multiple form with one action" New topic
Author

Multiple form with one action

Dorj Galaa
Ranch Hand

Joined: May 29, 2001
Posts: 113
Hello all
My jsp page contain 2 formsand name is form1 form2 . every form action is one action.jsp and method is post. how to read forms data.
see code
<form name="form1" method="post" action="action.jsp">
<input type="text" name="field1">
<input type="submit" name="Submit" value="Submit">
</form>
<form name="form2" method="post" action="action.jsp">
<input type="text" name="field1">
<input type="submit" name="Submit" value="Submit">
</form>


Senior software engineer
Thiru Thangavelu
Ranch Hand

Joined: Aug 29, 2001
Posts: 219
When you use POST the entire form object will be passed. So I think you can use the <formname>.<fieldname> to read the data. Correct me guys, If I am wrong.


Thanks,<br />Thiru<br />[SCJP,SCWCD,SCBCD]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You need to use request.getParameter(), reguest.getParameterValues() to read your form data.

Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I might add that if you click submit on form2, there is no way you can retrieve form1's data. And you can't nest forms either.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple form with one action