struts2struts1

Call Struts1 action from Struts2 application


We have 2 struts1 applications, earlier we have one call from one application to other.

In 1st application in config.xml we are calling 2nd application using below functionality,

    <forward name="inquiry" path="/inquiryaccount.do?prefix=/inquiry&amp;page=/inquiryconnect.do" redirect="false" />

    <action path="/inquiryaccount" type="org.apache.struts.actions.SwitchAction" />

And we have inquiryconnect.do present in other application config.xml

Now we have migrated one application from struts1 to struts2. And in struts2 config.xml (struts.xml) but I didn't found any SwitchAction like class to call other struts1 action.

I have tried with below but not working.

<result type="redirectAction">
                <param name="inquiry">inquiryconnect.do</param>
                <param name="namespace">/inquiry</param>               </result>

It is giving me 404.

Could anyone guide me please?


Solution

  • Answering my own Question.

    In Struts.xml, have a dynamic result such as:

    <result name="success" type="redirect">${url}</result>
    

    In the action:

    private String url;
    
    public String getUrl()
    {
     return url;
    }
    
    public String execute()
    {
         url = hostPath+"/appnametojump/actionclassname.do";         
         return "success";
    }
    

    By using above code now we can call Struts1 application from Struts2.