• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form submission

 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it possible to submit two forms in one jsp ,

 
Mahesh Kedari
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is possible but not on a single event.
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
will you please explain it
 
John Pradeep.v
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
may be you can write an onclick event handler on one form submission and trigger the second form (obtained by the id) submission through the script... not very sure of how it might work as I never tried it.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, this isn't really possible: a page can only submit a single form at a time. What would it mean to submit two forms? If they're submitting to the same action there's no need for two of them, and submitting to two places makes no sense.

You *can*, however, use an onsubmit/etc. to add form values or fill in hidden forms so the values from both forms are submitted to the *same* action.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you really trying to accomplish? Focus on strategy rather than tactics.
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i need to perform diffent action , i need to call two jsps for two differnt forms

can i call on submit on first form in that function i will submit both the forms

..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're still not telling us anything. You're focusing on tactics... what do you really need to do?
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok OK ... boss
My problem is i have input dialog when i click on submit button of input dialog i need to invoke another output page ,
after opening output page i need to refresh input page
i am doing this in process jsp,
the probelm is i need to send long url to putput page which is not working in IE by passing it as url parameter so i need do POST thats why i need two form submission in process JSP
so i can pass my parameters tru hidden fields ,,

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you don't need two submissions. If you a trying to work around a URL length issues, just use a POST rather than a GET and provide the params as hidden inputs to a post form.

You could also consider employing Ajax to make the request.
 
John Pradeep.v
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:No, you don't need two submissions. If you a trying to work around a URL length issues, just use a POST rather than a GET and provide the params as hidden inputs to a post form.

You could also consider employing Ajax to make the request.


Hi Bear, You are right in the solution... but just trying to look at his problem as a puzzle to solve, i think it should be possible to achieve the same affect of two form submission using 2 AJAX requests right? i mean two synchronous AJAX post requests without refreshing the page.


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, if you want multiple requests, Ajax is a way to do that. I still question the need for multiple requests though...
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I agree when anyone says that a HTML FORM cannot be submit twice. All's well and fine. Listen to something that happened to me a while back.

This involves a team mate and during a review I found that the person was using a <input type="button" onclick="javascript:..."> instead of a <input type="submit onclick="javascript:..."> for FORM submission. The idea was that the client side validations would be performed inside the script function and then a call would be made to document.forms[.].submit(); (in case of multiple forms on the same page, as is very common these days). I guess the necessary changes were made and later issues arose when a person tried to register him/her-self as an user (just another scenario). What was happening was given the credentials ANY user would always get the error message that the same user/user-id was already registered .... On checking the database we found that the user was inserted there and after multiple test sequences we deduced that such a thing is not really impossible?

Or maybe its a browser deal? But even though we tried on IE (forgot the version) and Firefox (the same applies) results were similar.

This whole deal is way beyond my comprehension (two form submissions from the same form, without AJAX). BUt hey does anyone wanna try this one out?

Raj.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm willing to bet you submitted the form twice. Check the validation script to see if there's a call to the form's submit() function. If so, the form is being submitted once by script, and once by the default action of the submit button.

Either don;t do it in script and let the button do its thing, don't use a submit button, or cancel the default action of the submit button by returning false from the event handler.
 
John Pradeep.v
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj Kamal wrote:

Or maybe its a browser deal? But even though we tried on IE (forgot the version) and Firefox (the same applies) results were similar.



Logically when a form is submitted, the browser opens a socket to the server to port 80 and sends an HTTP message, if another form submission happens then it will open another new socket and submit the content with an HTTP post message so in theory multiple form submission is possible if the browser interprets every user event independently in a new "thread" to handle socket creation and response interpretation, but it is not clear how will the browser handle 2 responses!!? will it consider the last response obtained as the response to process?

But in Practical, I think browsers have some restrictions in making multiple requests at the same time, we my have to dig into the implementation details to understand it in a better way.
I can assume that every interaction of the browser with any external Server should be sequential i.e., when a form is submitted the life of that page is expired and the browser just waits for the response for the first form submission and ignores listening to any new event on the already submitted page.

however, the exception is the usage of asynchronous AJAX in which case i believe the browsers would create a new thread to collect the AJAX response when it arrives and the page is always "alive" from the browsers perspective! Again, it all depends on the implementation details which could be actually different than what i said but may be a similar concept.


Thanks,
John
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok ... if i dont want to use any form submission i want pass my long long url using window.open() without any data lost ...

Is it possible with window.open to pass long url
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a limit to how long a URL can be, and it's browser-dependent.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic