tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Mast" <jhmast.develo...@gmail.com>
Subject How to programmatically add parameters to ServletRequest objects?
Date Wed, 06 Aug 2008 16:56:39 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message