Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActionContext & ValueStack in struts2

 
sarada bokka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

ActionContext holds the below all

1)parameters - Map of request parameters for this request
2)request - Map of request-scoped attributes
3)session - Map of session-scoped attributes
4)application - Map of application-scoped attributes
5)attr - Returns first occurrence of attribute occurring in page, request,session, or application scope, in that order
6)ValueStack - Contains all the application-domain–specific data for the request

I am having a variable name with getter & setter in my Action class ,is that it will store in the values in both parameters & value stack as mentioned above?

 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sarada chellub wrote:I am having a variable name with getter & setter in my Action class ,is that it will store in the values in both parameters & value stack as mentioned above?

It depends whether the variable (lets say username) came in as a request parameter or not. If the request did contain a parameter named username, then username will be in the parameters as well as the value stack (as the whole action object goes into the value stack)...
 
sarada bokka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,

Thanks for your input.

You have mentioned that username will be in the parameters as well as the value stack

what's the purpose of storing the value in both (parameters & value stack)?
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value will go into the value stack as its in the action and the action goes into the value stack. And as it was received as a request parameter, it will also be in the parameters map for any future actions or JSPs. If its removed from the parameters, any further action or JSP which might process the request might think that the request didn't have that parameter, this might confuse it into thinking that the parameter wasn't sent so the request should be aborted or an error message sent to the user...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic