Struts2 and how data is passed
Struts2 and how data is passed
(OP)
Hi! I'm new to Struts and have a question regarding how data can/should be passed between an action (extending ActionSupport) and the JavaServer page to which one is then redirected (according to the mapping done in the struts config file).
Should I explicitly store the action/JavaBean in the session object (from the action file) and then retrieve it from the JSP to which I'm redirected?. I've been reading the Struts 2.x documentation, but I can't quite wrap my head around it.
Or is there a Struts tag which can/should be used for this purpose, i.e. to access the fields/getter methods of a bean? The s:property tag for example? What I'm wondering is if the action/bean object is implicitly made available to the JSP by the framework, and can be accessed using a Struts tag.
Any input would be greatly appreciated.
Thanks.
Should I explicitly store the action/JavaBean in the session object (from the action file) and then retrieve it from the JSP to which I'm redirected?. I've been reading the Struts 2.x documentation, but I can't quite wrap my head around it.
Or is there a Struts tag which can/should be used for this purpose, i.e. to access the fields/getter methods of a bean? The s:property tag for example? What I'm wondering is if the action/bean object is implicitly made available to the JSP by the framework, and can be accessed using a Struts tag.
Any input would be greatly appreciated.
Thanks.
RE: Struts2 and how data is passed
RE: Struts2 and how data is passed
RE: Struts2 and how data is passed
Thanks again!
RE: Struts2 and how data is passed
Say I access an EJB from an Action. The method of the EJB returns some data. Is it good programming practice (in Struts) to store this data in the session object, later to be accessed from a JSP? This should allow me to pass the data, but perhaps there is some other alternative which is preferred. Storing information in the session object would maybe be good for data such as UserID, contents of a shopping cart, etc. The scope I believe I am interested in is request scope.
Would the preferred method then be to implement ServletRequestAware interface in the Action and store data of interest in the request object? Because I can't find any interceptor that does this. I'm sure one can also create user defined interceptors, but if there's a standard method for this provided by the framework, then I guess that would be the preferred way to go.
I'm grateful for any input on the matter. Cheers.