Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where is IllegalStateException ??? :)

 
Dan Polak
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone

I have two servlets and two doGet methods

first:


second:


I didn't get any exception but i think i should...
Can any one explain this?

regards
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

BEFORE dispatching a forward the buffer is cleared, so whatever is written before that point will not be sent to the browser.
AFTER dispatching a forward, before returning to the callee, "the response content must be sent and committed, and closed by the servlet container" (jsr). So, whatever you try after that, you can't send any more data to the client.

Consider that the specs say that you get an IllegalArgument exception if you commit something BEFORE calling the forward, and NOT after.
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The response has not been flushed, that's why.

Try flushing the response before the request dispatching process and you'll get an IllegalStateException.

Best of luck ...
 
Hendy Setyo Mulyo
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What web container are you using? Last time I also did flush the buffer before forward the request but no IllegalStateException was thrown. I was using Tomcat 5 at that time.
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Last time I also did flush the buffer before forward the request but no IllegalStateException was thrown. I was using Tomcat 5 at that time

Consider using Resin Web Server (http://www.caucho.com/). I myself used Tomcat and a few times found its behavior inconsistent with the Servlet specification.
 
Dan Polak
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mirko thanks for reply...

I know all of that... but it is strange for me

If I can't write anything to the client after forwarding I should get an exception in my opinion

regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic