I understand ValueStack
was introduced in Struts2 and one more change from Struts1 model is now a new ActionObject
is instantiated for each request. So we can define instance variables without worrying about multi threading issues.
The way interceptors and JSPs access the instance variables from the ActionObjects
is through the ValueStack
. But the way ValueStack
is implemented (or at least used by Struts2 framework) is by ValueStack
. to make the access easier so that we don't need to traverse the whole object tree. I have following questions.
What if I have embedded objects (multiple hierarchy of objects) ? how does the access mechanism behave in such a case?
If let us say 2 clients made requests to the same actin at the same time and the result of Action execution are different because the inputs provided by 2 clients came back with 2 different results. Let us say my Action Class has a method to get best price and based on the logic in my backend service the results come out as 10 and 12 for 2 different requests. Now
ActionClass
has a member variable called price in which this value will be stored and the resultant JSPshowResults.jsp
will access this variable (using a tag lib) to show the price. How does struts2 framework guarantee that client1 and client2 get the right response back and prices are not jumbled while the response is shown on the JSP because from what I understand theValueStack
just goes in first in first out (stack logic) fashion. So it might possibly end up returning 10 to both client requests as the same variable is stored twice (with the same name) on the value stack but with different values.When does the
ValueStack
destroy the object from its list?