Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forward to URL that contains parameters

Status
Not open for further replies.

forrozeiro

Programmer
Sep 1, 2001
38
BR
Hi,

Please, consider the following pages

test.jsp
% pageContext.forward( "test2.jsp?bla=2" ); %

test2.jsp
html body
%= request.getParameter( "bla" ) %
/body /html

When I call test.jsp, using JRun, I get "null". When I do the same call, using Tomcat, I get "2". Which one is right, Tomcat or JRun ? According to JSP specifications, should a forward of a request add in that request the URL's parameters ?

Thank you in advance,
forrozeiro.
 
The preferred way of forwarding in a JSP is:
Code:
<jsp:forward page=&quot;test2.jsp&quot;>
   <jsp:param name=&quot;bla&quot; value=&quot;2&quot; />
</jsp:forward>
One thing to note: The response can not be commited before the forward is sent. If it is then you will recieve an IllegalStateException. This also means that you must be very careful when using <jsp:forward> from an unbuffered JSP page.

As for your actual question, the functionality of Tomcat directly represents the JSP specification. Tomcat is the official reference implementation for Servlets/JSP. Wushutwist
 
Good day,

I'm using
Code:
<jsp:forward page=&quot;Cal.jsp&quot;>
   <jsp:param name=&quot;month&quot; value=&quot;<%=m%>&quot;/>
   <jsp:param name=&quot;year&quot; value=&quot;<%=y%>&quot;/>
</jsp:forward>

inside of an if statment. The page works fine as long as the if statment is not entered, but if it is, this code is executed and the page that this code is on is party displayed, for some reasone it'll only display the first bit of the page and stops way before it gets to this code, worst of all it doesn't forward.

any ideas? Thanks
________________________
JoelMac
 
Good day,

I'm using
Code:
<jsp:forward page=&quot;Cal.jsp&quot;>
   <jsp:param name=&quot;month&quot; value=&quot;<%=m%>&quot;/>
   <jsp:param name=&quot;year&quot; value=&quot;<%=y%>&quot;/>
</jsp:forward>

inside of an if statment. The page works fine as long as the if statment is not entered, but if it is, this code is executed and the page that this code is on is party displayed, for some reasone it'll only display the first bit of the page and stops way before it gets to this code, worst of all it doesn't forward.

I'm using Tomcat 4.

any ideas? Thanks
________________________
JoelMac
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top