Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IllegalStateException

 
Paulo Marcio Brandi Rezende
Ranch Hand
Posts: 34
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
sharad sinha
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jan Sterk
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you write to the response, and the buffer is full, the response is flushed & comitted. So writing could cause a commit.
 
Paulo Marcio Brandi Rezende
Ranch Hand
Posts: 34
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clarified. Thanks
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic