struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicolas De Loof" <nicolas.del...@cgey.com>
Subject Re: How to set a parameter in an action
Date Thu, 16 Jan 2003 10:25:39 GMT
Servlet API doesn't allow you to write request attributes (parameters,
headers...)

You can try to forward to a new ActionForward object, build with the mapping
to your "another" action, adding needed parameter with GET syntax :
...
return new ActionForward( NEXT_ACTION_URL + "?param=" + paramValue );
(I'm not sure it will work...)


Another solution is to put param value in request and forward to a JSP that
will redirect browser to the NEXT_ACTION_URL with param added :

# in your action:
request.setAttribute("param", paramValue);
return new ActionForward( "redirect.jsp" );


# redirect.jsp :
<form action="NEXT_ACTION_URL" method="POST">
  <input type="hidden" value="<% request.getAttribute("param") %>">
</form>
<script>
    document.forms[0].submit();
</script>


Nico.

> Hi,
> in my action-class I can get a parameter from the request by using the
> method getParameter(String); from the class HttpServletRequest.
> But now I want to set a parameter (not an attribute) in my action and then
> make the forward so that another action can read this parameter.
>
> I need it because normally the action gets the parameter by the URL. But
in
> this special case I have to send the parameter by an action.
>
> ciao Oliver.
>
>
> --
> To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>


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


Mime
View raw message