my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes flush and forward works ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "flush and forward works ?" Watch "flush and forward works ?" New topic
Author

flush and forward works ?

Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
HFSJ says, if you do flush and forward, a exception will be thrown
but no one will see the exception.The client will see 'Hi all' as a response from the sample.jsp but he wont see anything as a response from
other.jsp.

-----code in sample.jsp-----
Hi all
<%out.flush();%>
<jsp:forward page="other.jsp"%>

now please see thins question -

Consider the source for the following two JSP pages, a.jsp and b.jsp. What is the outcome of requesting each in turn? You can assume that �c.jsp� is available in the same web application directory as a.jsp and b.jsp. (Choose two.)

Source for a.jsp:
<%@page buffer="none" autoFlush="true"%>
<jsp:forward page="c.jsp"/>
Source for b.jsp:
<%@page buffer="none" autoFlush="true"%><jsp:forward page="c.jsp"/>
A. Neither JSP page translates.
B. a.jsp translates; b.jsp does not.
C. b.jsp translates; a.jsp does not.
D. Both JSP pages translate.
E. Neither JSP page runs successfully.
F. a.jsp runs successfully; b.jsp does not.
G. b.jsp runs successfully, a.jsp does not.
H. Both a.jsp and b.jsp run successfully.

of course D is one of the options.
keeping in mind the thing said in HFSJ, i selected H as the second option.
but the another answer given is G.

what i want to say is -



is equiivalent to



so D and H are the correct answers.

ok ?


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Vikrant Pandit
Ranch Hand

Joined: Mar 27, 2006
Posts: 245
Niranjan,


is not equivalent to


It simply means that the JspWriter will have no buffering .Remember that it is a page directive and it does not translate to any code in service method.Its just a instruction to the compiler

Since nothing is written to response stream by both the jsps , forward to c.jsp will work fine.

HTH
[ November 14, 2006: Message edited by: Vivek Pandey ]

Vikrant Pandit
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
Since nothing is written to response stream by both the jsps , forward to c.jsp will work fine.

hmm... i too thought the same !
hope some other rancher find the problem in the code !
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: flush and forward works ?
 
Similar Threads
jsp:include and %@include
RequestDispatcher include..
question of "include" in JSP spec 2.0
trick question : page directive + forward
specifying the exact location to display a jsp