Mapping problem for 2 simultaneous actions
------------------------------------------

                 Key: STR-3002
                 URL: https://issues.apache.org/struts/browse/STR-3002
             Project: Struts 1
          Issue Type: Bug
          Components: Core
    Affects Versions: 1.3.5
         Environment: Tomcat 5.5.9 - Mac OS X 10.4.8 - Struts 1.3.5 - Java 5.0
            Reporter: Eric Arlotti


I am experiencing a problem with Struts mapping for 2 actions that execute at 
the same time : the 2 actions are mapped to the same JSP page although I have 
defined 2 different JSP pages.

My web site has a home page with a frameset of 2 frames : 

<frameset>
        <frame name="DocsFrame" src="GetDocs.do?set=base">
        <frame name="CaddyFrame" src="GetCaddy.do?set=caddy">
</frameset>

The "GetDocs" action must retrieve all docs contained in a database, the 
"GetCaddy" action must retrieve the docs in a subset of the database that we 
call "Caddy".
Both actions are defined to call the same type of Struts Action called 
"ListDocsAction".

Here is how I define the 2 actions in "struts-config.xml" :

                <action
                        path="/GetDocs"
                        validate="false"
                        scope="request"
                        type="mydomain.actions.ListDocsAction">
                        <forward name="success" path="/views/DocsList.jsp"/>
                        <forward name="failure" path="/views/Error.jsp"/>
                </action>


                <action
                        path="/GetCaddy"
                        validate="false"
                        scope="request"
                        type="mydomain.actions.ListDocsAction">
                        <forward name="success" path="/views/CaddyList.jsp"/>
                        <forward name="failure" path="/views/Error.jsp"/>
                </action>


As you can see, in case of "success", the GetDocs action should be mapped to 
the "DocsList.jsp" page and the GetCaddy action should be mapped to the 
"CaddyList.jsp" page.
What happens in reality is that the 2 actions are mapped to the same JSP page 
(some time it's "DocsList.jsp", other time it's "CaddyList.jsp", it seems to 
depend on which action has terminated first).
It seems that the fact that the 2 actions execute almost simultaneously 
provokes a weird behaviour in Struts mapping.


For convenience, the class ListDocsAction extends an abstract class called 
GenericAction that implements things that are common to all actions in my 
project, like retrieving special parameters from the HttpServletRequest and 
mapping to "success" or "failure". All actions that extends GenericAction must 
call the "beginRequest" function first at the beginning of their "execute" 
method. Here is what GenericAction looks like :

-----------------------------------------------------

public abstract class GenericAction extends Action {

        private ActionMapping mapping = null;   
        private HttpServletRequest request = null;
        private HttpServletResponse response = null;

        protected void beginRequest(ActionMapping theMapping, 
HttpServletRequest theRequest, HttpServletResponse theResponse) {
                this.mapping = theMapping;
                this.request = theRequest;
                this.response = theResponse;
        }

        protected ActionForward success() throws Exception {
                return mapping.findForward("success");
        }

        
        protected ActionForward failure() throws Exception {
                return mapping.findForward("failure");
        }
}



And here is what looks like the ListDocsAction class :
-----------------------------------------------------
public class ListDocsAction extends GenericAction {

        public ActionForward execute(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response) throws Exception {
                beginRequest(mapping, request, response);

                // do some request to the data base to retrieves docs
                ....
                
                if (everythingIsOk) {
                        return success();
                }
                else {
                        retun failure();                
                }
        }
}


I have noticed that if I don't use the convenience method "success" and 
"failure" in my ListDocsAction class but use mapping.findForward("success") and 
mapping.findForward("failure") instead, the problem does not occur.


Eric Arlotti
[EMAIL PROTECTED]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to