GeeCON Prague 2014*
The moose likes Struts and the fly likes ActionContext & ValueStack in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionContext & ValueStack in struts2" Watch "ActionContext & ValueStack in struts2" New topic
Author

ActionContext & ValueStack in struts2

sarada bokka
Ranch Hand

Joined: Jan 13, 2010
Posts: 80
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

Joined: Aug 03, 2008
Posts: 9303
    
  17

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)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
sarada bokka
Ranch Hand

Joined: Jan 13, 2010
Posts: 80
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

Joined: Aug 03, 2008
Posts: 9303
    
  17

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...
 
GeeCON Prague 2014
 
subject: ActionContext & ValueStack in struts2