This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 2049
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: 2049
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: 2049
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).
 
 
subject: img tag empty src attribute causes duplicate form submission
 
Similar Threads
LookupDispatchAction
how to include image in JEditorPane ?
Buttons EventHandler and Property-Setting
Issue with weblogic 10 on struts form bean
Struts 2: Forms with multiple submit buttons - Best Practice?