Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HF - Chapter 5, Page 215, Question 1 (Errata Version)

 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've looked in the errata of this book and it says that the answer to Question 1 is incorrect.

"When using a RequestDispatcher, the use of which methods can often lead to an IllegalStateException?"
The errata says that the correct answers are (b) flush and (c) write.

I would just like to confirm that this is correct. (b) I understand, but (c) I find a little bit more dubious.

The API for RequestDispatcher says that an IllegalStateException will be thrown "if the response was already committed". I would not think that a write would result in a commit. Or is the commit non-deterministic? Is that why the question says "can *often* lead to an IllegalStateException", rather than "*will* lead to an IllegalStateException"? Might the stream autoflush?

 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with you. For me it is strange to talk about write() in that context. In the ServletResponse API for the getOutputStream method the javadoc specifies:

Calling flush() on the ServletOutputStream commits the response.


It does not talk about the write method on ServletOutputStream.
[ March 29, 2007: Message edited by: Sergio Tridente ]
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this help?
 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I conclude that the important word in the question is can. I hate questions like this. I've got the exam in a couple of days and I seem to spend all my time asking "What do they really mean by this question? Do they want me to be clever or not?"

Multiple choice limits my choices!
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!