This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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.
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 ]
Joined: Jul 02, 2003
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.