You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tom Ivers <ti...@gmail.com> on 2008/05/30 23:19:24 UTC

Interceptor problem - Struts 2.0.11.1

I am having a strange issue when utilizing a 'SecureInterceptor' I created.
I use this interceptor to ensure the user is logged in and if not, I send
them to the login page.  My struts.xml utilizes this interceptor as follows:

<struts>
    <package name="default" extends="struts-default">
        <interceptors>
            <interceptor name="secureInterceptor"
class="com.a.core.struts2.interceptor.SecureInterceptor" />
        </interceptors>

        <action name="logon" class="com.a.core.struts2.action.LoginAction">
            <result name="error">jsp/testing/loginfailure.jsp</result>
            <result name="success">jsp/template/main.jsp</result>
        </action>

        <action name="Site" class="com.b.struts2.action.SiteAction">
            <interceptor-ref name="secureInterceptor"/>
            <result name="success">jsp/testing/sitesuccess.jsp</result>
            <result name="login">jsp/login.jsp</result>
        </action>
    </package>
</struts>

Although my LoginAction properly calls the 'getMethods' when submitting a
form in login.jsp, the SiteAction one does not (both utilizing s:form tags
on their respective Action).  If I remove the interceptor from the Site
definition it works 'properly'.  Has anyone else seen this or proven it
worked ok as I explained?  Has anyone had the same or a similar problem?

login.jsp (clip)
<s:form action="logon">
  <s:textfield label="User Name" name="username"/>
  <s:password label="Password" name="password" />
  <s:submit/>
</s:form>
site.jsp (clip)
<s:form action="Site">
    <s:hidden name="id" />
    <s:textfield disabled="true" key="entity.code" name="code" />
    <s:textfield key="site.friendlyname" name="friendlyName" />
    <s:textfield key="entity.address1" name="address1" />
    <s:textfield key="entity.address2" name="address2" />
    <s:textfield key="entity.city" name="city" />
    <s:textfield key="entity.state" name="state" />
    <s:textfield key="entity.postalCode" name="postalCode" />
    <s:textfield key="entity.country" name="country" />
    <s:submit/>
</s:form>

I am sort of stumped and hope I am not doing something silly.

Thanks,

Tom

Re: Interceptor problem - Struts 2.0.11.1

Posted by Tom Ivers <ti...@gmail.com>.
Ok - I found out why.  It seems that an Action will utilize the defaultStack
if nothing is specified.  Once I specified my 'secureInterceptor' I no
longer utilized the defaultStack.  Simply adding the defaultStack as an
interceptor to my action fixed the issue.  I mistakenly thought that the
action would continue to inherit the 'default-stack' with an additional
specified.  The 'Guide' doesn't clearly state either way.



Tom Ivers wrote:
> 
> ... fixed (from original)...
> <struts>
>     <package name="default" extends="struts-default">
>         <interceptors>
>             <interceptor name="secureInterceptor"
> class="com.a.core.struts2.interceptor.SecureInterceptor" />
>         </interceptors>
> 
>         <action name="logon"
> class="com.a.core.struts2.action.LoginAction">
>             <result name="error">jsp/testing/loginfailure.jsp</result>
>             <result name="success">jsp/template/main.jsp</result>
>         </action>
> 
>         <action name="Site" class="com.b.struts2.action.SiteAction">
>             <interceptor-ref name="defaultStack"/>
>             <interceptor-ref name="secureInterceptor"/>
>             <result name="success">jsp/testing/sitesuccess.jsp</result>
>             <result name="login">jsp/login.jsp</result>
>         </action>
>     </package>
> </struts>
> 
> 

-- 
View this message in context: http://www.nabble.com/Interceptor-problem---Struts-2.0.11.1-tp17568150p17570580.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org