On Fri, 14 Feb 2003, Kevin Williams wrote:

> Date: Fri, 14 Feb 2003 15:22:47 -0800 (PST)
> From: Kevin Williams <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: HELP! get request parameter from a custom tag
>
>  Hi,
>
> I apologize if this already was posted...I posted this earlier today, but
> did not get see it posted...
>
> If anyone can help me with this, it's stopping me from finishing key
> portions of my applicaiton!
>
>  I'm new to struts, and I am trying to retrieve a parameter that is in
>  the request scope from a tag library.  Currently, I can print out the
>  parameter on my jsp page using request.getParameter(name), but in my
>  pageContext object in my tag library, I don't have the same list or
>  request paramters, all I have are the Struts Form object, Bean object,
>  and Error object.
>
>  Somewhere Struts has overriden the default request object, and
>  implemented it's own before my custom tag is called.  Would someone
>  please tell me how I can retrieve the JSP page's request attributes in my
> custom tag?
>

Struts does not (and indeed *can* not in a Servlet 2.2 / JSP 1.1
environment) override the request object.  I suspect you might be getting
confused between request *parameters* (things that came in on the original
request) and request *attributes* (things an Action might have put there).

>From within a tag implementation, you can get to request parameters like
this:

  String foo = pageContext.getRequest().getParameter("foo");

While request attributes can be retrieved like this:

  String foo = pageContext.getAttribute("foo", PageContext.REQUEST_SCOPE);

Because you mentioned "request scope", I'm betting that the latter is what
you really want to use.

>  Thanks in advance,
>
>  Kevin Williams

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to