• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
reply
    Bookmark Topic Watch Topic
  • New Topic