Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

submitting two forms with one button click from JSP

 
DeepakN kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Nam Ha Minh
Ranch Hand
Posts: 504
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's impossible! Why don't you combine two forms into one, and two actions into one?
 
DeepakN kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but there are 2 windows . form per window. i.e, submit per window.
 
DeepakN kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DeepakN kumar wrote: both are same?

it is same here :)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic