aspose file tools*
The moose likes Servlets and the fly likes what are the possible reasons for request  getting submitted twice? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "what are the possible reasons for request  getting submitted twice?" Watch "what are the possible reasons for request  getting submitted twice?" New topic
Author

what are the possible reasons for request getting submitted twice?

Christian Nash
Ranch Hand

Joined: Jan 17, 2006
Posts: 107
hi,

in my application, the request is getting submitted twice even though i'm submitting the form only once by clicking on the submit button? What might be the possible reasons for the request getting submitted twice?


- Christian
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
How do you know that its getting submitted twice ?


Rahul Bhattacharjee
LinkedIn - Blog
Christian Nash
Ranch Hand

Joined: Jan 17, 2006
Posts: 107
through the log messages..i see that the requests are getting submitted twice, one after the other..and both are POST
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

never exclude the possibility that your logging may be wrong.

If you have validation on the form, the following will cause the form to the submitted twice:



The form gets submitted by both the initial submit AND the form.submit()
[ May 09, 2007: Message edited by: David O'Meara ]
Christian Nash
Ranch Hand

Joined: Jan 17, 2006
Posts: 107
I have the following validation on the form


How is the above different from the below:

Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
With return false, the form will not be submitted. Returning true will cause it to be submitted if the action is onSubmit.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Bosun Bello:
With return false, the form will not be submitted. Returning true will cause it to be submitted if the action is onSubmit.


I do not think returning false from the javascript will help.It will still resubmit the form.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Christian Nash:



How is the above different from the below:



What is the use of the validation function that you are putting ? its just submitting the form.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I believe we're getting side tracked. We know what the problem is and why, shouldn't we concentrate on removing one?
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
what is <html:image... sounds like JSF to me which I have a very limited idea of. The rason that comes to my mind is that the request is getting submitted twice because the <htm:image... is being rendered as a submit button for the form. something like <input type="image" .... See the generated code to see if that's the case. So in that case when you click on the image, the image would submit the request and inturn also call the submit method which would again submit the method. Try removing the submit from the submit() function and see if it helps.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

The problem is exactly as previously stated: the click of the image button (which has submit semantics) is initiating a form submission. Within the handler, the form is also be submitted under script control by calling submit. The results is a double submission.

Either the original submission must be derailed (by returning false from the handler), or the submit() method should not be called. I;d opt for the latter as the call is completely unecessary.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what are the possible reasons for request getting submitted twice?
 
Similar Threads
Can I use IDE to create GUI?
using saveToken() and isTokenValid() methods in struts
Preventing form submission twice on doubleclick in NN6.
java regex issue
No suitable driver found