File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes what commits the response ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "what commits the response ?" Watch "what commits the response ?" New topic

what commits the response ?

Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
hfsj says,

flush( ) commits the response.
so we cant call anything on the response ( methods to do sendRedirect( ) and adding/setting things in the response ), once we say flush( ).

my query is if, after the response is commited, and i say
out.println( ), where out is a PrintWriter, what will happen ?

SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

If the response is commited you cant forward to any other servlet. You have to choose. Either commit the response and handle the content yourself or forward to another servlet/JSP without commiting the response

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 10032

It will give you an IllegalStateException as it is given in the specs.

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
I agree. Here's the link:
subject: what commits the response ?
It's not a secret anymore!