Ok, got it.
If not logged in, you are returning an global result, login
, that is a chain
result type, then a call to another action.
The login
result type is under the same Interceptor Stack containing the nLogin Interceptor
.
This means that when you try to chain your login
result, you pass AGAIN inside your nLogin Interceptor
, checking again if user
is null, and returning login
result, in and endless loop.
You can:
return a JSP instead of chaining to another Action, like this:
<result name="login">myLogin.jsp</result>
or move your global result login
outside your custom Interceptor Stack scope (putting it under the default stack in a parent package, for example), like this:
<struts>
<package name="defaultPackage" extends="struts-default" >
<default-interceptor-ref name="defaultStack"/>
<global-results>
<result name="login" type="chain">
<param name="actionName">myLoginAction</param>
</result>
</global-results>
</package>
<package name="myLoginProtectedPackage" extends="defaultPackage">
<interceptors>
<interceptor name="nlogin" class="interceptors.LoginInterceptor"/>
<interceptor-stack name="loginStack">
<interceptor-ref name="nlogin"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="loginStack"/>
<global-results>
<result name="input" type="chain">
<param name="actionName">myLoginAction</param>
</result>
</global-results>
<action name="myLoginAction" class="...">
<result>myLogin.jsp</result>
</action>
</package>
</struts>
Don't ask me why with redirectAction works... it should be the same, but probably is due to their different behavior.
Please note that, according to the guide,
As a rule, Action Chaining is not recommended. First explore other options, such as the Redirect After Post technique.