File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Multiple form submit in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Multiple form submit in jsp" Watch "Multiple form submit in jsp" New topic
Author

Multiple form submit in jsp

Mayank Adhikari
Greenhorn

Joined: Nov 17, 2012
Posts: 12
I am having a jsp file in which there are two different forms "f1" & "f2". I am having below three conditions

1. I have to submit form f1 only
2. I have to submit form f2 only
3. I have to submit form f1 & f2 both

for 3rd condition mentioned above, i need a single button by which i can submit both the form f1 & f2.
currently i am using the below java script but its now working ane giving me null value when i am trying for both form submission.

Please find below my jsp code:
harshvardhan ojha
Ranch Hand

Joined: Jul 26, 2007
Posts: 157
    
    1

why don't you combine both fields in a single form? What is the business need?

If you can't do that, before submitting your form set value of a field in hidden field of other form.
Mayank Adhikari
Greenhorn

Joined: Nov 17, 2012
Posts: 12
Hi,

In the above code i just show two fields where in actual i have 40+ fields (including some drop downs) so using hidden value will be a bit problematic.

i need to have separate form submission option because i have three scenarios as mentioned in the initial post.
so can you please sugget me on a alternative.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

You cannot submit two forms at the same time.

You haven't really explained why you feel that you need to.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mayank Adhikari
Greenhorn

Joined: Nov 17, 2012
Posts: 12
thanks for the reply..

On my page i am giving the flexibility to user that they might only enter the data for one form and keep the other for blank. then i need to update the single form only.
If user enter data in both forms then i have to update the full data.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Still not seeing why there needs to be two forms.
harshvardhan ojha
Ranch Hand

Joined: Jul 26, 2007
Posts: 157
    
    1

try solving this problem using ajax.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

I'd like to hear more about what's actually trying to be accomplished before jumping to Ajax.
Bill Clar
Ranch Hand

Joined: Sep 21, 2006
Posts: 153

Why not use one form with two different submit buttons? Use only the form data you need based on the submit button the user presses.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple form submit in jsp