File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Multiple Submit button in one jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Multiple Submit button in one jsp" Watch "Multiple Submit button in one jsp" New topic

Multiple Submit button in one jsp

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I have a have a deal.jsp. In this I have two buttons
one for query and one for submit.
<title>Untitled Document</title>
<form name="form1" action="multitest.jsp" method="post">
<input type="text" name="textfield">
<input type="submit" name="Submit2" value="Submit Whole Form">
<form name="form2">
<input type="text" name="textfield2">
<input type="text" name="textfield21">
<input type="submit" name="Submit" value="Query">
On load of this page I will get values from Bean and database and load it most of the values are in form1.
In form2 textfield2 user enters soem value and clicks on query button and then i need to go to database and get some more value and place them in form2 textfield21.
finally user clicks on form1 then i want take all values form form1 as well as form2 to submit it to process.jsp.
How do i achive this? When user clicks on query i have to get value form database but without submitting anything.
any help appreciated.
Maky Chopra
Ranch Hand

Joined: Apr 11, 2001
Posts: 149
You can do this is a lot of different ways.. your query could take you to page 3 where you get the data from the db and redirect to page2 while keeping all the data from form1 and form2 in sessions.. That way process.jsp will also be able to pick up the data from sessions where necessary.
Another interesting way (and I havn't tried this) is remotehostscripting.. here is an artical on it.. let us kow if it works..
I agree. Here's the link:
subject: Multiple Submit button in one jsp
jQuery in Action, 3rd edition