• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

flush and forward works ?

 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 !
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic