You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shih-gian Lee <st...@gmail.com> on 2004/11/29 01:24:27 UTC

Re: How to retrieve parameters passed via GET method?

> In my Struts configuration file, an action element is defined as the following:
> <action    path="/closeAccount"    type="org.apache.struts.actions.ForwardAction"    parameter="/closeAccount.jsp" />
> 
> When customer clicks on the hyperlink, ActionServlet receives the HTTP request, pre-processes it and forwards it to ForwardAction, who will simply forward the request to closeAccount.jsp. That page then asks customer to confirm the operation ("are you sure that you want to close account No. 100?"). The problem is, ActionServlet seems to have modified the request, so in my closeAccount.jsp, i cannot retrieve the accountId parameter: request.getAttribute("accountId") returns null.
> 
> I dumped the contents in the HTTP request that closeAccount.jsp receives. They look like this:
> javax.servlet.forward.request_uri = /badba/closeAccount.do javax.servlet.forward.context_path = /badba javax.servlet.forward.servlet_path = /closeAccount.do javax.servlet.forward.query_string = accountId=100 org.apache.struts.action.mapping.instance = ActionConfig[path=/closeAccount,parameter=/closeAccount.jsp,scope=session,type=org.apache.struts.actions.ForwardAction org.apache.struts.action.MODULE = org.apache.struts.config.impl.ModuleConfigImpl@2b249
> 

Is it possible that the accountId is saved in session scope instead of
request scope?

You need to specify the scope if you want to save it in "request" scope:

<action path="/closeAccount"
type="org.apache.struts.actions.ForwardAction"   
parameter="/closeAccount.jsp" scope="request"/>

HTH.

Lee

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


RE: How to retrieve parameters passed via GET method?

Posted by Robert Taylor <rt...@mulework.com>.
The accountId value is in the query string of the request and therefore must
be retrieved like:

String accountIdValue = request.getParameter("accountId");

robert

> -----Original Message-----
> From: Shih-gian Lee [mailto:struts.user@gmail.com]
> Sent: Sunday, November 28, 2004 7:24 PM
> To: Struts Users Mailing List
> Subject: Re: How to retrieve parameters passed via GET method?
>
>
> > In my Struts configuration file, an action element is defined as the following:
> > <action    path="/closeAccount"    type="org.apache.struts.actions.ForwardAction"    parameter="/closeAccount.jsp" />
> >
> > When customer clicks on the hyperlink, ActionServlet receives the HTTP request, pre-processes it and forwards it to
> ForwardAction, who will simply forward the request to closeAccount.jsp. That page then asks customer to confirm the
> operation ("are you sure that you want to close account No. 100?"). The problem is, ActionServlet seems to have modified
> the request, so in my closeAccount.jsp, i cannot retrieve the accountId parameter: request.getAttribute("accountId") returns null.
> >
> > I dumped the contents in the HTTP request that closeAccount.jsp receives. They look like this:
> > javax.servlet.forward.request_uri = /badba/closeAccount.do javax.servlet.forward.context_path = /badba
> javax.servlet.forward.servlet_path = /closeAccount.do javax.servlet.forward.query_string = accountId=100
> org.apache.struts.action.mapping.instance =
> ActionConfig[path=/closeAccount,parameter=/closeAccount.jsp,scope=session,type=org.apache.struts.actions.ForwardAction
> org.apache.struts.action.MODULE = org.apache.struts.config.impl.ModuleConfigImpl@2b249
> >
>
> Is it possible that the accountId is saved in session scope instead of
> request scope?
>
> You need to specify the scope if you want to save it in "request" scope:
>
> <action path="/closeAccount"
> type="org.apache.struts.actions.ForwardAction"
> parameter="/closeAccount.jsp" scope="request"/>
>
> HTH.
>
> Lee
>
> ---------------------------------------------------------------------
> 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