| Author |
submitting two forms with one button click from JSP
|
DeepakN kumar
Greenhorn
Joined: Apr 14, 2012
Posts: 27
|
|
Hi,
I have a requirement to submit two forms ( each form to a different strut action class ) on click of a submit button from JSP. Any idea how this can be achieved? Is it OK if i write a java script method and inside the method i write the two form submit as below?
Please let me know if there is any other way of doing it.By the way form1 will submit to a different url (different application) and form2 will submit to an action class on the same application.
Also i have read that two forms can't be submitted from a JSP at the same time.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56207
|
|
You cannot submit two requests at the same time. Which one's response would show up in the browser?
Back up. Why do you need to do this. There is surely a better way.
(P.S. You could possibly use Ajax, but I'm not sure that's the best approach.)
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Nam Ha Minh
Ranch Hand
Joined: Oct 31, 2011
Posts: 346
|
|
|
That's impossible! Why don't you combine two forms into one, and two actions into one?
|
Job Offer: Online working Java technical writing
|
 |
DeepakN kumar
Greenhorn
Joined: Apr 14, 2012
Posts: 27
|
|
ok. Let me explain my requirement in detail.
I have an OK button on my JSP and on click of that OK button, i am suppose to send some parameter as POST to another application in a new window( i.e. a new browser window should open on click of OK). At the same time, i also need to forward the request to another screen which is a summary screen on the same application. So it is not possible for me to combine these two activities into one.
Also how Ajax can help here?
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
DeepakN kumar wrote:
If you submit 2 forms, the last one will get submit . so this is not correct approach. and I think, I got your requirement. just follow the below steps,
create 2 forms like below, first one will be your main window and second form will be submitted to your popup(see the target attribute)
and onclick javascript
does that make sense?
|
 |
DeepakN kumar
Greenhorn
Joined: Apr 14, 2012
Posts: 27
|
|
|
thanks i will try this. But i have one question. Here also there is two form submit right? So in this case also only the last submit will work right? (document.getElementByID('go').click) ? Please could you explain?
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
|
but there are 2 windows . form per window. i.e, submit per window.
|
 |
DeepakN kumar
Greenhorn
Joined: Apr 14, 2012
Posts: 27
|
|
|
thanks alot. Also is there a difference between submitting the form by document.getElementById("go").click() and document.getElementById("hidden").submit()? both are same?
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
DeepakN kumar wrote: both are same?
it is same here :)
|
 |
 |
|
|
subject: submitting two forms with one button click from JSP
|
|
|