File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple form with one action

 
Dorj Galaa
Ranch Hand
Posts: 113
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use request.getParameter(), reguest.getParameterValues() to read your form data.

Bosun
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic