I don't know of any performance differences, but I am not a struts expert.
I think that the static methods of ServletActionContext were provided
exactly for this reason, namely convenience, so you don't need to deal
with casting. Also, if the internal working objects change in a later
struts release, then casting might be broken, while the static api is
more likely to remain the same.

You can have a look at the source code of the ServletConfigInteceptor.
I learned from it how ActionContext actually works. However, that code
is at a higher level of expertise (as is expected from the struts
developers, I suppose), so I just stick with the thread local
approach.

On 6/13/07, chengas123 <[EMAIL PROTECTED]> wrote:

Thank you both for your responses.  While I had tried going down the
ActionInvocation.getInvocationContext(...) road I didn't see anything
interesting that way and probably would have never thought to cast it to a
ServletActionContext (although hopefully I will next time).  I'm using the
ThreadLocal approach right now for brevity.  Is there any performance
difference or other difference between the two approaches that I should be
aware of?



Yoni Amir-2 wrote:
>
> 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 <[EMAIL PROTECTED]> wrote:
>> 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.
>>
>> d.
>>
>

--
View this message in context: 
http://www.nabble.com/-S2--Accessing-HTTP-Header-tf3907721.html#a11100917
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to