• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

submitting two forms with one button click from JSP

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

DeepakN kumar wrote: both are same?


it is same here :)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic