struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Pratt <thechrispr...@gmail.com>
Subject Re: struts 2 Intercepter ServletRequestAware
Date Fri, 24 May 2013 00:42:34 GMT
It's static, you call it just like I sent in the previous email
  (*Chris*)
On May 23, 2013 4:55 PM, "john lee" <sh_thorn_bird@yahoo.com> wrote:

> in the interceptor,
>
> in order to access ServletActionContext, in the interceptor class, which
> interface should be implement?
>
> tks in advance
>
> john
>
>   ------------------------------
>  *From:* Chris Pratt <thechrispratt@gmail.com>
> *To:* Struts Users Mailing List <user@struts.apache.org>; john lee <
> sh_thorn_bird@yahoo.com>
> *Sent:* Thursday, May 23, 2013 6:25 PM
> *Subject:* Re: struts 2 Intercepter ServletRequestAware
>
> ServletActionContext.getRequest().getCookies()
>   (*Chris*)
>
>
> On Thu, May 23, 2013 at 4:20 PM, john lee <sh_thorn_bird@yahoo.com> wrote:
>
>
>
> thanks,
>
> so, how can I access Cookie in the interceptor? as my knowledge, to access
> cookie, i have to get Servlet first, then get Request object, then access
> Cookie..
>
> please advise
>
>
>
> john
>
> ________________________________
>  From: Chris Pratt <thechrispratt@gmail.com>
> To: Struts Users Mailing List <user@struts.apache.org>; john lee <
> sh_thorn_bird@yahoo.com>
> Sent: Thursday, May 23, 2013 5:02 PM
> Subject: Re: struts 2 Intercepter ServletRequestAware
>
>
> You cannot use ServletRequestAware or ServletResponseAware in an
> Interceptor.
>   (*Chris*)
>
>
> On Thu, May 23, 2013 at 2:58 PM, john lee <sh_thorn_bird@yahoo.com> wrote:
>
> > please explain more, thanks in advance
> >
> >
> > ________________________________
> >  From: Dave Newton <davelnewton@gmail.com>
> > To: Struts Users Mailing List <user@struts.apache.org>
> > Sent: Thursday, May 23, 2013 4:53 PM
> > Subject: Re: struts 2 Intercepter ServletRequestAware
> >
> >
> > You may have misunderstood what I said.
> >
> > those interfaces are for actions, not interceptors.
> > On May 23, 2013 5:51 PM, "john lee" <sh_thorn_bird@yahoo.com> wrote:
> >
> > > it is interceptor, the following is struts.xml, (i just not include
> last
> > > time)
> > >
> > > <struts>
> > >  <package name="default" extends="struts-default">
> > >
> > >         <interceptors>
> > >              <interceptor name="securityverifysessionIntercepter"
> > > class="SecurityVerifySessionIntercepter">
> > >              </interceptor>
> > >              <interceptor-stack name="SecurityStack">
> > >                <interceptor-ref
> name="securityverifysessionIntercepter"/>
> > >              </interceptor-stack>
> > >         </interceptors>
> > >
> > >           <action name="LoginAction" class="LoginAction">
> > >                     <interceptor-ref name="SecurityStack"/>
> > >                     <result name="input">PageLogin.jsp</result>
> > >                     <result name="success">PageMain.jsp</result>
> > >        </package>
> > >
> > > </struts>
> > >
> > >
> > >
> > > ________________________________
> > >  From: Dave Newton <davelnewton@gmail.com>
> > > To: Struts Users Mailing List <user@struts.apache.org>
> > > Sent: Thursday, May 23, 2013 4:31 PM
> > > Subject: Re: struts 2 Intercepter ServletRequestAware
> > >
> > >
> > > That interface is for actions, not interceptors.
> > > On May 23, 2013 5:30 PM, "john lee" <sh_thorn_bird@yahoo.com> wrote:
> > >
> > > > Please advise the following
> > > >
> > > > for struts2, for an login action, an predefined interceptor is
> > triggered
> > > > for checking cookie , the code is the following
> > > >
> > > > for  SecurityVerifySessionIntercepter, i implement the
> > > > ServletRequestAware, but get null catached.
> > > >
> > > > my question is:
> > > >
> > > > for intercepter, Request object can not be implemented? if can, why i
> > get
> > > > null?
> > > >
> > > > thanks in advance
> > > >
> > > > john
> > > >
> > > >
> > > >
> > > > public class SecurityVerifySessionIntercepter extends
> > AbstractInterceptor
> > > > implements ServletResponseAware, ServletRequestAware {
> > > >
> > > >
> > > >     protected HttpServletResponse servletResponse;
> > > >     public void setServletResponse(HttpServletResponse
> servletResponse)
> > > >               { this.servletResponse = servletResponse; }
> > > >
> > > >     protected HttpServletRequest servletRequest;
> > > >     public void setServletRequest(HttpServletRequest servletRequest)
> {
> > > > this.servletRequest = servletRequest; }
> > > >
> > > > public String intercept(ActionInvocation invocation) throws
> Exception {
> > > >
> > > >        ActionContext ctx=invocation.getInvocationContext();
> > > >       Map session= ctx.getContext().getSession();
> > > >
> > > >          if (servletRequest==null)
> > > >              System.out.println(" Request object is null catched");
> > > >           Cookie cookieList[]=servletRequest.getCookies();
> > > >
> >
>
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message