• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does write() commit a response?

 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thus is my question.

say if I have


Does it commit the response? I mean will the write() here cause IllegalStateException? My understanding is yes, but need clarification and confirmation.

Thanks.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends of a few thing, especially of the buffer size, and autoflushing. If the buffer size is exceeded after writing, the response will be flushed, and you may get an Exception.
 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to page 215 of HF, the errata chose the option C, i.e. write() commits a response and often causes IllegalStateException.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is this all you've got in the question ?
 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question does not even provide such codes. It is simply asking which method. The errata includes the "write()", but the original print on my book only selects "flush()", so I am curious about it.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the question exactly ? (sorry don't have the book)
If it's something like "which may cause an Exception", then the answer is correct.
 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the question stem:

"When using a RequestDispatcher, the use of which methods can often lead to an IllegalStateException?"

I think I have to take write() as "often leads to" this exception, even if it only commit when the buffer is full.
[ March 05, 2007: Message edited by: warren li ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, "can often lead" is the tricky part of the question.

Don't worry to much about that, there's no such confusion at the real exam.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic