Questions tagged [actioncontext]

The ActionContext is a Struts 2 container for objects needed by the application when the action is executed.

The ActionContext is a Struts 2 container for objects needed by the application when the action is executed. An action context used to access those objects during the the action execution. When Struts2 request is handled by the framework it creates an ActionContext and populate it with the framework core objects, such as request, session, application, valueStack, servlet context objects, parameters, locale, etc. The benefit of this is there's no need to worry about a user specific action context, and it could get statically from the class ActionContext which is ThreadLocal in every request.

References:

66 questions
2
votes
1 answer

Struts2 : Interceptor is being only one time instead of two times

I am working on Struts2 Interceptors . I have read that Struts2 Interceptors are just like Filters , which execute before the Action class is executed and one more time after processing the result ( Please correct me if i am wrong ) , that is two…
user663724
2
votes
6 answers

How do you get a Struts2 value from the .properties file programatically?

Say I have a struts.properties file with a defined value uploads.directory . How can I access that value from an Actioncontext programatically?
Josh
  • 10,352
  • 12
  • 58
  • 109
2
votes
2 answers

Best and recommended approach to get session in struts2?

There are many ways to get session object in struts2. Which one is best and recommended approach to get session object from the following?. ActionContext SessionAware Getting Request from ServletRequestAware and after session from request…
dbyuvaraj
  • 487
  • 1
  • 6
  • 20
2
votes
1 answer

Mocking ActionContext.getContext().getSession() returns null

I am trying to write jUnit test case for following method. public class MyClass { public static Map getSession() { Map session = ActionContext.getContext().getSession(); return session; } } I followed…
want2learn
  • 2,471
  • 2
  • 20
  • 37
2
votes
2 answers

What objects are stored in ValueStack

This is my code below, when I execute it shows me the size 3, but when I pop the object out I am getting only 2 objects. import java.util.*; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.ActionContext; import…
Sachin Singh
  • 49
  • 1
  • 6
2
votes
1 answer

Is ValueStack container thread-safe?

Action classes are thread-safe since Struts filter creates new action object for each request. All the action objects along with variables will be stored in ValueStack. So, Is the ValueStack container thread-safe? Could we able to take values form…
2
votes
1 answer

Struts2 and Hibernate - Access ActionContext.getContext().getSession() outside a Servlet

I try to access ActionContext.getContext() outside a Struts (Struts2) action in 2 different situations and I get a different result, regarding from where I am trying: From CurrentTenantIdentifierResolverImpl an (my) implementation of…
Charles
  • 41
  • 7
2
votes
2 answers

Why use ServletRequestAware instead of ServletActionContext?

To get a servlet request in Struts 2 we can use either ServletRequestAware or ServletActionContext. However, in a particular internet resource, it is told that ServletRequestAware should be used instead of ServletActionContext. Does that have…
The Dark Knight
  • 5,455
  • 11
  • 54
  • 95
2
votes
1 answer

What is action context in Struts 2

I don't understand this author: context, properties of the default or root object. ..based on a context I'm stuck at reading this portion of the tutorial: http://www.tutorialspoint.com/struts_2/struts_value_stack_ognl.htm "The OGNL is very similar…
user3769040
  • 235
  • 4
  • 14
2
votes
2 answers

Get/set ServletRequest attributes from ActionContext

I need to set a ServletRequest attribute within a Struts2 interceptor (not action class). Does the ActionContext expose a Map to control request attributes, like it does for session attributes? I see ActionContext implements a map.…
Glenn Lane
  • 3,892
  • 17
  • 31
2
votes
2 answers

Get it in action but no display in s:iterator tag

I use ....... and I have seen replies…
王奕然
  • 3,891
  • 6
  • 41
  • 62
1
vote
0 answers

Handling session with Struts 2 and Spring security 3

I am trying to integrate Struts 2 and Spring security 3. I don't understand how to handle session, with both.Is there a standard way? I know of struts session built in session handling, ActionContext eg Map session =…
user230272
  • 63
  • 6
1
vote
1 answer

Will a new ActionContext and ValueStack be created for every new action object?

My questions are: 1) In Struts2, does every action object have its own corresponding ActionContext and ValueStack? In other words, for every new request a new action object is created. Does this mean every time a new action object is created, a new…
a Learner
  • 4,944
  • 10
  • 53
  • 89
1
vote
1 answer

ActionContext.getContext() returns null using Session in Struts 2

I am trying to use Session in Struts 2: private Map session = ActionContext.getContext().getSession(); But I'm getting this error: Exception in thread "main" java.lang.NullPointerException: Cannot invoke…
Riyaz
  • 28
  • 6
1
vote
1 answer

what is the difference between ActionContext and ValueStack in struts2

I am unable to understand how parameters go into ValueStack . How the parameters are passed. what is the use of value stack and ActionContext? I am having a variable name with getter & setter in my Action class,where will be the values be stored.
coder25
  • 2,363
  • 12
  • 57
  • 104