• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About Flush Before Include/forward

 
Sanjay pts
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a code

case:1 with <jsp:forward>
-------------------------
<%
out.println("Before forward/include");
out.flush();
%>
<jsp:forward page="test.html" />

<%
out.println("After forward/include");
%>

a)Container throws Exception
b)output displayed => Before forward/include.


case2:: <jsp:include>
------

<%
out.println("Before forward/include");
out.flush();
%>
<jsp:include page="test.html" />

<%
out.println("After forward/include");
%>

a)container will not throw exception
b)it will deisplay
Before forward/include
include test.html
After forward/include


It means in <jsp:include> if we commit the response and then we will include then it doesn't make difference.


Please correct me if i'm wrong ???

sanjay
 
sergio mendez-rueda
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sanjay,
if you have already comitted *A* response,
your app is death no ... for... ;-). You are over.
if you deploy your examples:
this is the answer:
IllegalStateException.
commitDeath,
ser
 
Sanjay pts
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But i think its of

response.sendRedirect(String URL)
and
RequestDispatcher.forward().

but not for
RequestDispatcher.include()
or<jsp:include page="" />

Please correct me if im wrong

Thanx
sanjay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic