• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

commiting response...

 
Nikhil Jain
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • 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...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic