2

Our application (still using Struts 1) needs to redirect the user to a new login page (hosted externally). In a similar application (using Struts 2), we have this working properly. Below, I will show our implementation. Ultimately I want to find the equivalent in Struts 1. I am having trouble finding any online documentation because of this old unsupported software. I would greatly appreciate any advice here.

struts.xml:

<action name = "Home2" 
         class = "com.eppt.action.MasterAccountListAction2" 
         method = "wlgnReDirect">
          <result name = "unknownerror" type = "tiles">masteraccountlist</result>  
         <result name="wlgn" type="redirect">${wlgntUrl}</result>
         <result name="success" type="redirect">${wlgntUrl}</result>
</action>

redirect config Java file:

 public String wlgnReDirect() {
    try {
         wlgntUrl = "https://wwwdev.idev.com/secure-login/en-us/?redirectUrl=http://www.yahoo.com";
        nextScreen = "wlgn";
    } catch (Exception e) {
        addGenericError(request);
        return "unknownerror";
    }
    return nextScreen;
}

Like stated above, this works as intended in Struts 2. How can I achieve the same in Struts 1?

Roman C
  • 49,761
  • 33
  • 66
  • 176
JCP
  • 169
  • 1
  • 7

1 Answers1

2

In Struts 1 the same result could be achieved if you create a new ActionForward programmatically and return it from the action method.

public ActionForward wlgnReDirect(ActionMapping m, ActionForm f, HttpServletRequest req, HttpServletResponse res) throws Exception
{
    try {
         wlgntUrl = "https://wwwdev.idev.com/secure-login/en-us/?redirectUrl=http://www.yahoo.com";
        nextScreen = "wlgn";
    } catch (Exception e) {
        addGenericError(request);
        return m.findForward("unknownerror");
    }
    return new ActionForward(redirectUrl, true);
}
Roman C
  • 49,761
  • 33
  • 66
  • 176