• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Illegal State exception example

 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Creator of Enthuware JWS+ V6
Posts: 3398
312
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Thank you for replying.I am using Tomcat 5.5 .

 
Veena Pointi
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic