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 Re-entrancy in actionclass execute() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Re-entrancy in actionclass execute() method" Watch "Re-entrancy in actionclass execute() method" New topic
Author

Re-entrancy in actionclass execute() method

Harish Verma
Ranch Hand

Joined: Feb 27, 2006
Posts: 32
I am facing a situation where program control enters the execute() method twice for a single action performed on the JSP page. Strange as it sounds, I have confirmed this several times over - during debug, the control reaches execute() method beginning (where I have set a breakpoint) twice - sometimes after the business and model layers have been navigated, and sometimes before that!

At the end of an execute method, I return an action forward that is defined as a forward within the <action>...</action> tags in struts-config.xml. Pls tell me - if I perform mapping.findForward(forwardName), will this action throw control back to the action execute() method, or will it just open the target JSP specified in forwardName?

Any ideas how to deal with this re-entrancy?

Any insight is valuable and will be appreciated. Thanks in advance.
[ April 19, 2006: Message edited by: Harish Verma ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This can happen when you do "action chaining". By action chaining, I mean forwarding to another action instead of a JSP. Do your forwards contain entries that point to actions like this:

<forward name="success" path="/myAction.do" ></forward>

If so, this may be causing the problem.


Merrill
Consultant, Sima Solutions
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This problem could also be the same as the one identified in this thread
Harish Verma
Ranch Hand

Joined: Feb 27, 2006
Posts: 32
The actionforwards all point to JSPs. But the link you posted solved my problem - the issue was that I had a html "submit" type and in the onClick() event, it was calling a function that performs validations and eventually submits the same form.

Problem solved. Thanks, Merrill.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Ya gotta love that...one post fixes two problems! Like they say...even a blind squirrel finds a nut occasionally...even the losers get lucky sometimes....when you...(sorry, it is getting close to 5:00 and the outside temp is around 80 degrees and I guess I am getting a little stir crazy). ;-) Glad I could help.

- Brent
Harish Verma
Ranch Hand

Joined: Feb 27, 2006
Posts: 32
Originally posted by Brent Sterling:
Ya gotta love that...one post fixes two problems! Like they say...even a blind squirrel finds a nut occasionally...even the losers get lucky sometimes....when you...(sorry, it is getting close to 5:00 and the outside temp is around 80 degrees and I guess I am getting a little stir crazy). ;-) Glad I could help.

- Brent


Now if only they had reward points, you could've earned a double bonus... It's not often one stone kills two birds! But dont worry, folks here should already be thinking here's a real html expert... Thanks.
 
jQuery in Action, 2nd edition
 
subject: Re-entrancy in actionclass execute() method