Bilal
Bilal

Reputation: 2740

Struts2 Result, Thread safety, and Action Context?

In Struts2

Keeping these things in mind, I believed that

I found following line of code in book "Manning Struts2 in Action" while creating a custom result class.

ServletActionContext.getResponse()

I am confused why author did not get response using actionInvocation object i.e.

actionInvocation.getInvocationContext().get(StrutsStatics.HTTP_RESPONSE);

Now I have following questions in my mind.

Upvotes: 0

Views: 1136

Answers (1)

Dave Newton
Dave Newton

Reputation: 160251

Contexts use ThreadLocals.

Results are clearly instantiated per-request--look at something simple, like StreamResult: it uses instance variables for things like contentType and so on.

Upvotes: 3

Related Questions