Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Illegal State exception example

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

In HFSJ it says you will get IllegalStateException if we try to forward request after committing response.I tried following code ,it works fine



Can anyone please explain what specs is trying to say?

Thanks
Veena
 
Walid Abd Elsalam
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you try it again after replacing OutputStream with ServletOutputStream. I'm just wondering if it would make a difference as the api documentatio for OutuptStream.flush() says it does nothing.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried your example on tomcat5.5 and I am getting the IllegalStateException: Cannot forward after response has been committed

what server are you using?
Regards,
Frits
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Thank you for replying.I am using Tomcat 5.5 .

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Walid Abd Elsalam wrote:Can you try it again after replacing OutputStream with ServletOutputStream. I'm just wondering if it would make a difference as the api documentatio for OutuptStream.flush() says it does nothing.


Doesn't matter weather OutputStream or ServletOutputStream right?Because spec says


forward should be called before the response has been committed to the client
(before response body output has been flushed). If the response already
has been committed, this method throws an IllegalStateException.


I wonder how my code is working!!!

Thanks
Veena
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I checked the logs.It is showing the IllegalStateException . What I thought was it will throw exception on the browser itself without even processing the page .

Thank you .

Veena
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic