• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

jsp:include and request dispatcher

 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose two files, a.jsp and b.jsp:
code for a.jsp:
<html>
<head><title>a.jsp</title></head>
<body>
<br>this is a's content...<br>
<br>included code:<br>
(1)
</body>
</html>

code for b.jsp:
<%@page language='java'%>
<br>this is b's content...<br>

%%%%%%%%%%%%%
if we replace (1) with <jsp:include page='b.jsp'/> or <jsp:include page='b.jsp' flush='true'/>
we are going to have the following will appear in the browser:

this is a's content...
included code:
this is b's content...

but if we replace (1) with:<%request.getRequestDispatcher("b.jsp").include(request,response);%>
the following will be printed:

this is b's content...
this is a's content...
included code:
Could someone clarify this...
Thanks in advance
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leandro,
If you use dispatcher, it will forward to the b.jsp page first then include the a.jsp page. Therefore the result is different from doing <jsp:include>.

Paul
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic