• Post Reply Bookmark Topic Watch Topic
  • New Topic

IllegalStateException in servlets  RSS feed

 
sai rama krishna
Ranch Hand
Posts: 524
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When do i get IllegalStateException in servlets.

What it means by trying to write to the output stream (response) after the response has been committed by server. What it means by committing response and uncommitting response. cannot i send uncommitted response. please advise
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A response is committed when the first buffer load of text is sent.

The first buffer load will of course contain headers and possibly part of the response body. Since you can't change header information after it has been sent, trying to do so gets an exception.

Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's definitely a sign that you are doing something you should not be. Perhaps you could give us more details regarding the code that is causing the error?
 
Sooraj Rajagopalan
Ranch Hand
Posts: 40
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, consider a scenario where a single object is accessed two different threads simultaneously. The first thread invalidates the object and when the second thread tries to read the object which is now invalidated, the JVM throws an illegal state exception.
you can read more about exceptions here by following the link.

http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalStateException.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!