This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

commiting response...

 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I don't understand the meaning of "Commiting the response". For example in case of forward, if we commit the response, we get IllegalStateException... In the HFS it says, if you use methods like flush(), we get IllegalStateException, but my question is why will some use this method...

will this generate illegalstateexception
writer.println("testetest");
RequestDispatcher view = request.getRequestDispatacher("dddd.jsp");
view.forward(request, response)

Can some one please explain...
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This might cause an IllegalStateException, if the buffer has been flushed before forward is called. It depends if the response is buffered. If it is, it depends also on the size of the buffer. If you've output more than the size of the buffer, the response will be committed, and an exception will be thrown when forwarding.
 
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To add on to what Satou has said:

If you set autoFlush=true and buffer=0kb then it will cause IllegalStateException.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

autoFlush=true and buffer=0kb


maybe autoFlush=true or buffer=0kb ?
 
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

maybe autoFlush=true orbuffer=0kb ?



Well, if autoFlush=true (which is the default) and buffer size(default=8kb) is not reached, then the exception would not be raised. (Which is what you had stated earlier...

(So I had used the and instead of or).

Regards,
Shivani
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic