Forums Register Login

A puzzle on pageContext.include & request. getRequestDispatcher. include

+Pie Number of slices to send: Send
Hi,
I have three JSPs, they are a.jsp, b.jsp and test.jsp.
Can you tell me why the following codes run to a different result?
Please pay attention to the line "AAAAAAAAAAAAAAAA"
and the line "this is bbbbbbbbbbbbbb.jsp" in the results.
/////////////////////////////////////////a.jsp:
<br>this is aaaaaaaaaaaa.jsp
/////////////////////////////////////////b.jsp:
<br>this is bbbbbbbbbbbbbb.jsp
/////////////////////////////////////////test.jsp:
<html><body>
<br>AAAAAAAAAAAAAAAA
<%pageContext.include("a.jsp");%> <%//pageContext line%>
<br>BBBBBBBBBBBBBBBB
<%request.getRequestDispatcher("b.jsp").include(request, response);%>
</body></html>
the output in the IE browser:
AAAAAAAAAAAAAAAA
this is bbbbbbbbbbbbbb.jsp
this is aaaaaaaaaaaa.jsp
BBBBBBBBBBBBBBBB
/////////////////////////////////////////test.jsp
//(with the line
//< %pageContext.include("a.jsp");% > < %//pageContext line% >
//deleted):
<html><body>
<br>AAAAAAAAAAAAAAAA
<br>BBBBBBBBBBBBBBBB
<%request.getRequestDispatcher("b.jsp").include(request, response);%>
<br>CCCCCCCCCCCCCCCC
</body></html>
the output in the IE browser:
this is bbbbbbbbbbbbbb.jsp
AAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBB
thanks!
pie. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1121 times.
Similar Threads
RequestDispatcher include..
A puzzle on pageContext.include & request. getRequestDispatcher. include
RequestDispatcher.include
jsp:include and request dispatcher
"pageContext.include"
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:22:42.