File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Groovy Fundamentals video training course this week in the Groovy 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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Multiple form with one action