I can't figure out how to use the pageContext.forward() method like it's
equivalent script element:

<jsp:forward page="page.jsp" >
    <jsp:param name="foo" value="bar"/>
</jsp:forward>

How do I pass the name-value pair "foo":"bar" using pageContext.forward()? I
thought there would be a method like forward(String path, Map params) but
there isn't.

Nor is there a setParameter(name, value) method available on ServletRequest
or ServletResponse (both of which are passed onto the page pointed to in
pageContext.forward().

I don't want to put the parameters in the url itself (ie "page.jsp?foo=bar")
this approach is not scalable.

And I don't want to continue doing what I'm doing now, which is:

<%
     if (blah) {
%>
<jsp:forward page="page.jsp" >
    <jsp:param name="foo" value="bar"/>
</jsp:forward>
<%
     } else if (...) {
%>
<jsp:forward ......
<%
....
%>

Not very pretty and rather error prone.

Thanks in advance

JDK 1.4.2

Reply via email to