I am calling the forward() method of the RequestDispatcher. After the call, in the calling servlet, is the response.isCommited method alway return true. That is, I want to know Does the response alway commited after call to forward method? Nothing is given in the Specifiactions.
Since you didnt call the flush method in the caller servlet/jsp the output stream inst closed and you can use the output stream in the calling servlet without matters. If you flush so a fat IllegalStateException will be throwed.
I am not talking about closing of the out stream. After the forward method return to the calling Servlet, Can I use the out stream in any condition ?. In my testing the isCommited() method retrun alway true.
Even after calling forward, we can have logic that does not write to the stream. Its not good programming but its valid.
Intuitively it makes sense that isCommited should return true after forwarding the request. if isCommited returns false then it would mean that we could write to the stream which is not correct.
SCBCD (Preparing) <br />SCWCD, 82%<br />SCJP, 90%
Joined: Dec 04, 2004
I want to know that the out.iscommited() method always return true or some case it can return false (i.e I can write to stream). For the sendError, sendRedirect methods of the HttpServletResponse it is clearly stated in Specs that After using these methods, the response should be considered to be committed and should not be written to. But for the forward() method for RequestDispatcher is is not specified anywhere. Though it is not good parctice to write after the forward method, I want to confirm it in view of Exam (There is seperate piont on RequestDispatcher)