You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by plen <pe...@earthlink.net> on 2009/02/12 15:23:06 UTC

Returning request parameters in action class... How?

Hello,

I have an action class which might get a request parameter when called (ex.
request.getParameter("mode")).  When the action class returns SUCCESS which
ends up calling a JSP, I need to be able to send that request parameter on
to the JSP.  I believe I could just use the request.setAttribute("mode",
mode) in the action class and then have the JSP do a getAttribute, but it
seems that Struts must already have a way of doing this.  So, the question
is "how do you pass parameters from the action class to the JSP"?

Any thoughts?

Thanks - Peter Len
-- 
View this message in context: http://www.nabble.com/Returning-request-parameters-in-action-class...-How--tp21977049p21977049.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Returning request parameters in action class... How?

Posted by plen <pe...@earthlink.net>.
Sonny,

Great.  Thanks for the reply.

- Peter


-- 
View this message in context: http://www.nabble.com/Returning-request-parameters-in-action-class...-How--tp21977049p21978514.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Returning request parameters in action class... How?

Posted by Sonny Gill <so...@gmail.com>.
Unless you are using a redirect, the JSP already has access to that
parameter since it is still the same request.
If you are using JSTL, you can access it as ${param.mode}.

Some people prefer not to access request parameters directly in JSPs,
which is a good thing IMO. In that case, you can create the same field
in the Action class, Struts will set it from the request parameter,
then you can access it using Struts tags, for examle <s:property
name="mode" />.

HTH

Sonny

On Thu, Feb 12, 2009 at 10:23 PM, plen <pe...@earthlink.net> wrote:
>
> Hello,
>
> I have an action class which might get a request parameter when called (ex.
> request.getParameter("mode")).  When the action class returns SUCCESS which
> ends up calling a JSP, I need to be able to send that request parameter on
> to the JSP.  I believe I could just use the request.setAttribute("mode",
> mode) in the action class and then have the JSP do a getAttribute, but it
> seems that Struts must already have a way of doing this.  So, the question
> is "how do you pass parameters from the action class to the JSP"?
>
> Any thoughts?
>
> Thanks - Peter Len
> --
> View this message in context: http://www.nabble.com/Returning-request-parameters-in-action-class...-How--tp21977049p21977049.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org