File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

IllegalStateException

Paulo Rezende
Ranch Hand

Joined: May 13, 2008
Posts: 33

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?

Answer:

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?


SCJP, SCWCD, OCBCD
sharad sinha
Greenhorn

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 Rezende
Ranch Hand

Joined: May 13, 2008
Posts: 33

Clarified. Thanks
Sunny Jain
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: http://aspose.com/file-tools
 
subject: IllegalStateException