• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ out.write() jsp:forward

 
lars carlsson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
On page 416 it say that you can�t use out.flush() and then make a <jsp:forward page= />. Can you make a out.write() and then <jsp:forward page= /> ?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by lars carlsson:
Hi
On page 416 it say that you can�t use out.flush() and then make a <jsp:forward page= />. Can you make a out.write() and then <jsp:forward page= /> ?


What you get at the time of execution?
 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by lars carlsson:
Hi
On page 416 it say that you can�t use out.flush() and then make a <jsp:forward page= />. Can you make a out.write() and then <jsp:forward page= /> ?


I think no..please see the first Mock question of this chapter...Correct me,if wrong
 
Shruthi Sam
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use out.write("") and then <jsp:forward /> , i think it will work. please correct me if am wrong
 
Victor Dolirio
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, you can do it, but remember... when you forward the request you�re saying that you aren�t responsible to the result of response, in this case, assuming you don�t called the out.flush(), the container will clear all buffered data in out object before it forward the request.
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its guaranteed that if you flush the buffer and then do a forward you will get a IllegalStateException.
out.flush();
<jsp:forward page="x.jsp"/>

However if you do
out.write("x");
<jsp:forward page="x.jsp"/>
Then you might not get exception because here all the data will be stored in the buffer and will not be flushed unless it fills up.
Default buffer size is 8kb and autoFlush attribute of page directlive is true.
Hence if you have 8kb of data before jsp:forward then container will flush it automatically and hence there is a possiblity that you can get exception out.write("x");
<jsp:forward page="x.jsp"/>

I hope am correct.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic