File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Action executed two times Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Action executed two times" Watch "Action executed two times" New topic
Author

Action executed two times

Mnau Lubi
Ranch Hand

Joined: Mar 17, 2010
Posts: 32
Hi all!

I am having a strange problem. When I click a link in my webpage the action attached to that click is called twice instead of just once... Then, when the action is finished for the 2nd time, it goes where the action forward says. The action works perfectly but it does it two times which is a big problem since the action consist of writing in a database (it writes the same two times ). Anyone knows what could be happening?

Thanks
vijay jamadade
Ranch Hand

Joined: May 12, 2008
Posts: 241
please send the code. Have you used html:submit and also submitting the form through javascript.


Regards, Vijay Jamadade.
( Nothing is Impossible.)
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Hi,

On a project one of my team mates faced something of the same sort. Each form had a simple button which would invoke a javascript function call and the function would submit the form based on the status of the form validation. Later this button was changed to a submit button and the same situation arose. Debugging revealed that the form was getting submitted twice. Once with the html submit button. And the next time with the javascript form.submit() call.

I felt it was worth a metion as you could probably have a similar situation. For any more thoughts you ought to post more detail...

Cheers,
Raj.
Mnau Lubi
Ranch Hand

Joined: Mar 17, 2010
Posts: 32


When I click in Join, the action /join is called two times
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

http://struts.apache.org/1.2.x/userGuide/struts-html.html#button

If you're not inside a form, don't use Struts 1 form tags.

May not solve the problem, but it's still incorrect.
Mnau Lubi
Ranch Hand

Joined: Mar 17, 2010
Posts: 32
David Newton wrote:http://struts.apache.org/1.2.x/userGuide/struts-html.html#button

If you're not inside a form, don't use Struts 1 form tags.

May not solve the problem, but it's still incorrect.


Yes that was the problem. However I liked how it looked like when it was with buttons, is it any alternative you can suggest to me?

Thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Just use an HTML button w/o the Struts tag?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Action executed two times