This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Methods executing twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Methods executing twice" Watch "Methods executing twice" New topic
Author

Methods executing twice

Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
Hi,
I am facing a strange problem. In my struts based application, certain methods are being executed twice. In some of these methods I am doing database transactions and those transactions are also being done twice.
Has anyone faced this problem?
Please tell me what can be done to avoid this problem.
Thanks,
Abhishek.
Franck Tranchant
Ranch Hand

Joined: Aug 07, 2003
Posts: 75
Hi

If your action methods , including database access etc.. are executed twice, you can be 99% sure that your actions are actually called twice.
Incorrect use of javascript could explain that kind of behaviour.

Don't you have some javascript coded in your JSP's on events like onclick/onsubmit/image+href.. ?
If so, double-check the 'return' value to avoid your Form being posted twice.


Franck<p>--------------------
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
follow up to franck's comment. the most common problem is using html:submit (or input type submit) along with a javascript submit, instead of html:button (or input type button).


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Methods executing twice
 
Similar Threads
Multiple Transactions
db access inside static methods
Focus Lost - Getting called twice.
Synchronized keyword will help to resolve ny defect?
java bean each line twice being executed twice