You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Prafulla Nawale <pn...@vertex.co.in> on 2006/07/28 15:05:15 UTC

Problem while submiting the page

Hi,
I am facing one problem on submit of jsp.
I think its most probably an issue related to javascript. Can you please help me in figuring out it.

There is a button on the screen, on click of that button i invoke the javascript function and in that function i submit the form two times, to two different actions.

So what happens mostly in this case is only the second action is executed. I can see the log corresponding to second action only. 

Can anyone please help me in solving this.

the code snippet in js is like this

var win = window.open("", "checklist", features);
document.formMain.target = "checklist";
document.formMain.action = '../..' + actionPath + '/' + link + '?uniqeId='+uniqeId + '&ref=' + refName;
document.formMain.submit();
document.formMain.target = "checklist";
document.formMain.action = '../../PrintOut/Polling/Polling.do?uniqeId='+uniqeId + '&ref=' + refName;
document.formMain.submit();

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Problem while submiting the page

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Hi,

I think you might be running into a timing issue.  I would suggest 
this... onClick of the button, first, disable the button, and then set a 
timeout, set for like 1 millisecond (which is probably a lower 
resolution than is available, but it will basically fire immediately, 
that's what you want).  Do the submission to the first action.  Then, in 
that timeout function, start another timeout for maybe 500 millisecond. 
  When it fires, make the second submission.  I'm guessing that the 
first request doesn't begin before the code starting the second one 
fires.  This timeout scheme should avoid that.

Alternatively, have another form on the page with ll the same elements, 
but hidden.  Then just have a bit of Javascript to iterate over the 
elements of the real form and transfer them to the second form.  Then 
just submit both forms, each one targeting a different action.

One other option, and probably the one I'd go for myself, is instead of 
submitting the form at all, make two AJAX requests, one to each action. 
  The submit button would be an ordinary button to avoid its own submit 
getting in the way.  It would be a little more work on your part, since 
you have to handle the response, but any of the libraries available 
today will make it childs' play.

Frank

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
  (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
  Supplying the wheel, so you don't have to reinvent it!

Prafulla Nawale wrote:
> Hi,
> I am facing one problem on submit of jsp.
> I think its most probably an issue related to javascript. Can you please help me in figuring out it.
> 
> There is a button on the screen, on click of that button i invoke the javascript function and in that function i submit the form two times, to two different actions.
> 
> So what happens mostly in this case is only the second action is executed. I can see the log corresponding to second action only. 
> 
> Can anyone please help me in solving this.
> 
> the code snippet in js is like this
> 
> var win = window.open("", "checklist", features);
> document.formMain.target = "checklist";
> document.formMain.action = '../..' + actionPath + '/' + link + '?uniqeId='+uniqeId + '&ref=' + refName;
> document.formMain.submit();
> document.formMain.target = "checklist";
> document.formMain.action = '../../PrintOut/Polling/Polling.do?uniqeId='+uniqeId + '&ref=' + refName;
> document.formMain.submit();
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Problem while submiting the page[OT]

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Prafulla,

FYI, this post is totally off-topic. Please indicate it as such.

> There is a button on the screen, on click of that button i invoke the javascript function and in that function i submit the form two times, to two different actions.

This is not going to work: the web wasn't intended to work that way. You
should only submit one form at a time.

> 
> So what happens mostly in this case is only the second action is
> executed. I can see the log corresponding to second action only.

That's (likely) because the second form submission interrupts the first
one before it even starts.

If you need to submit the same information to two places, take care of
it on the server side: submit the information to a single form handler,
and then forward that same request to the second form handler. This
still isn't a really great idea, as it suggests an awkward application
logic, but ... whatever.

-chris