struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yoni Amir" <amir.y...@gmail.com>
Subject Re: [S2] Accessing HTTP Header
Date Wed, 13 Jun 2007 08:02:28 GMT
Here is an interceptor that I use to manipulate the HttpResponse
object. You can do the same for the HttpRequest.

public String intercept(ActionInvocation actionInvocation) throws Exception {
  HttpServletResponse resp = ServletActionContext.getResponse();
  resp.setHeader("Pragma", "no-cache");
  // etc ...
}

Notice that ActionContext (and ServletActionContext) is ThreadLocal.
That's why this code is so concise.


On 6/13/07, Dave Newton <newton.dave@yahoo.com> wrote:
> --- chengas123 <benjamin.j.mccann@gmail.com> wrote:
> > However, now I'm having the problem that I can't
> > figure out how to access the HTTP request headers
> > from the interceptor.
>
> Follow the yellow brick API...
>
> What's the signature of Interceptor.intercept?
>
> String intercept(ActionInvocation)
>
> What's an ActionInvocation? Oh, it's an interface. One
> thing that looks particularly interesting is
> ActionInvocation.getInvocationContext(...) -- it's
> interesting because it contains the word "context".
>
> Okay, that returns an ActionContext. One
> *particularly* interesting implementation of
> ActionContext is ServletActionContext.
>
> > Is ServletRequestAware meant to be used only in
> > Actions?  I am receiving a null HTTP Request Servlet
>
> > in my Interceptor.
>
> Um... yeah. Well, I mean, you can use it anywhere you
> want, but the framework (AFAIK) only pays attention to
> it in Actions, where an interceptor uses it to decide
> if it needs to set anything in the Action.
>
> d.
>
>
>
>
> ____________________________________________________________________________________
> Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo!
Answers - Check it out.
> http://answers.yahoo.com/dir/?link=list&sid=396545433
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Mime
View raw message