File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes img tag empty src attribute causes duplicate form submission Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "img tag empty src attribute causes duplicate form submission" Watch "img tag empty src attribute causes duplicate form submission" New topic
Author

img tag empty src attribute causes duplicate form submission

Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
On an html 'button' on my html page, I call an 'onclick' function. It does a xxx.action="/cccc", and forms[0].submit() after that.

It results in 2 submissions of the form, resulting in 2 (duplicate) calls to my server processing.

Googling had me informed that an empty src on an img (src="") causes it. I tried and filled the src with a dummy src, and it fixed my problem.

Any one knows the explanation of why the src="" affects my form submission?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
What is the exact email, why would you have an empty img tag?

Eric
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
Below is the related parts. (struts 1 is involved)



Initially, I dont need to put an entry in the src because I 'hide' it using css.

The src value also is dynamic.

By the way, in the above code, I typed in src="", but it doesnt appear in the post.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
I didnt notice the 'disable html'.

Ill make a small web app to isolate the issue, and post the generated html here (if the issue happens).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: img tag empty src attribute causes duplicate form submission