• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Post executed twice when user clicks button to submit details

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a vexing problem. When a user clicks a struts html:image button, it seems that the POST is executed twice - resulting in two database inserts when only one should have been made. I'm using WSAD 501 and a tomcat 406 server.
The flow of execution is as follows:
The user clicks a menu item to request the page.
This 'fires an init action' that places several arraylists in the session scope - and then the init action forwards to the actual jsp that the user will use to enter his details.
This JSP contains two sets of logic:equal tags.
When the user makes a certain selection he has to fill in more details which is shown as a second 'view' in a wizard-style fashion.
The logic:equal tag sets enclose two tables each with its own html:image button.
After the user has filled in his details and if the user is not required to do the extra step and the user clicks to submit the form, then the console shows that the POST was executed twice for the /registrationAction. For a single click, all the sys outs appear twice and two inserts are made into the db. The interesting things is that each of the two inserts have unique ids that a business bean provides.
I'm at a loss as to why this is happening - a single click executes the POST twice.
I would really appreciate any advice. I've googled and can't seem to find any solution. I've changed scopes and implemented the registration differently but still the same thing happens.
Please let me know if I need to provide code etc.
Many thanks in advance.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Zane, are you perhaps executing a Javascript form.submit() within an onsubmit handler? That is one situation where I've seen this happen.
hth,
bear
P.S. Welcome to the Ranch!
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, I've seen the same thing in IE when you have a submit button that executes functionality that also results in a submit... ie:

The combination of input type=submit and myForm.submit() causes the form to be submitted twice for a single click.
(oh, and UBB doesn't like on_click, hence the underscore)
Dave
[ yoiks, smilie error ]
[ July 02, 2003: Message edited by: David O'Meara ]
 
Zane Tofie
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great stuff, spot on - thank you guys! I removed the call to the java script and implemented image button beans as explained in a tip by Ted Husted - and it works just fine now.
 
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic