aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes HF SCJP mock exam question: flush() vs. write() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "HF SCJP mock exam question: flush() vs. write()" Watch "HF SCJP mock exam question: flush() vs. write()" New topic
Author

HF SCJP mock exam question: flush() vs. write()

Jean-Christian Imbeault
Greenhorn

Joined: Dec 08, 2004
Posts: 19
Chapetr 5, page 209, mock exam question #1 asks:

"When using a requestDispatcher, the use of which method can often lead to an IllegalStateException (choose all that apply):

A. read
B. flush
C. write
D. getOutputStream
E. getResourceAsStream

The correct answer is given as B, but I would have though the answer should have been B *and* C.

Couldn't writing 'theoretically' cause the response to be commited and hence cause and IllegalStateException if we try and forward the request?

Or is it in the specification that nothing is sent to the browser until flush() is called or the servlet's service method returns?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Is this not an SCJP 1.2 mock question?


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Jean-Christian Imbeault
Greenhorn

Joined: Dec 08, 2004
Posts: 19
Oops! Wrong forum. Sorry!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HF SCJP mock exam question: flush() vs. write()