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
BE (Computer Science) SCJP 4 (80%) SCWCD 5 (97%) IBM CAD(98%) IBM CAppD(100%) IBM SD(100%)
Joined: Jul 09, 2008
If you use out.write("") and then <jsp:forward /> , i think it will work. please correct me if am wrong
Joined: Aug 21, 2008
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.
If happen something bad in you life, don't ask God why it happened. Ask for what.
SCJP 5 (80%) - SCWCD 5 (91%) - SCBCD & SCJD coming soon...
Joined: Aug 05, 2006
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"/>