Help coderanch get a
new server
by contributing to the fundraiser
  • 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

where is IllegalStateException ??? :)

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ...
 
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic