• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat variable behavior with IllegalStateException

 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

After the response is committed by out.flush(), why does response.sendError() not throw an IllegalStateException? Or is the exception thrown but not visible?
[ March 13, 2007: Message edited by: Aniket Patil ]
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your server's console for the exception. It won't show on the browser because, well, the response was already sent to the browser before the exception occurred.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one can use the response.isCommited( ) as a precaution !
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's useful Niranjan.
Mark, i looked at the Tomcat console window to se if i could get an exception, but wasn't able to find any.

I'm facing a similar problem with the following code too:



I remember i had an IllegalStateException for the above, since i'm trying to forward after committing the response. This is also mentioned on Pg. 205 of K&b. But since today, i have stopped getiing the exception and "Got beer color" gets printed in the browser.

Why does Tomcat exhibit such variable behavior?
[ March 13, 2007: Message edited by: Aniket Patil ]
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, is this an issue with Tomcat?
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've read topics around here that mention that Tomcat isn't fully J2EE-compliant. I've switched to Resin now and i'm getting the expected results.

I'm able to get an IllegalStateException if i try to forward()/sendRedirect() after a flush().
The curious thing is, the text i am sending through flush() is getting printed to browser and THEN an exception is raised. With Tomcat (when i got the exception once), no text was printed.
[ March 14, 2007: Message edited by: Aniket Patil ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this an issue with Tomcat

It sounds like one. I've a few ranchers complaining about that recently.
 
Rancy Chadha
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aniket,

I tried the code snippet that you gave on tomcat ver 5.0 and it did give me IllegalStateException. What I wanted to know from you is that, did you check your log files i.e the text file for the day you ran this code under logs folder? It should reflect IllegalStateException there.

Thanks,
-Rancy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic