Meaningless Drivel is fun!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes IllegalStateException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "IllegalStateException" Watch "IllegalStateException" New topic


Paulo Marcio Brandi Rezende
Ranch Hand

Joined: May 13, 2008
Posts: 34

In HFSJ 2nd Edition, Mock Exam Chapter 5, we have:

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


B. flush
C. write

But in the Java� Servlet Specification Version 2.4, section SRV 5.3, we have:

If data has been written to the response buffer, but not returned to the client (i.e. the response is not committed), the data in the response buffer must be cleared and replaced with the data set by these methods. If the response is committed, these methods must throw an IllegalStateException.

Reading the specification I understood that a write does not cause a IllegalStateException.

Somebody can help me?

sharad sinha

Joined: Jul 13, 2008
Posts: 26
Even I have doubt on this answer.
Actually discussions in the chapter gives clear impression that only flush will cause this exception, But I am not sure why in the answer for this question they included write.

Thanks, Sharad<br />SCJP 5 (July, 2008)
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
If you write to the response, and the buffer is full, the response is flushed & comitted. So writing could cause a commit.

SCJP 1.4 (81%)<br />SCWCD 5 (95%)
Paulo Marcio Brandi Rezende
Ranch Hand

Joined: May 13, 2008
Posts: 34

Clarified. Thanks
Deepak Chopra
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

this also depend upon the size of buffer. If the amount of data you have written exceed the buffer size, then obviously it will be flushed..!

Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
I agree. Here's the link:
subject: IllegalStateException
jQuery in Action, 3rd edition