According to javadoc:
forward should be called before the response has been committed to the client (before response body output has been flushed).Uncommitted output in the response buffer is automatically cleared before the forward.
I am getting confused when this response is committed or been flushed?
is this writing in
Best How To :
flush() on the
PrintWritercommits the response.
forward method allows one servlet to do preliminary processing of a request and another resource to generate the response.
You can have many
out.write statements before forwarding but you can't call
flush before forwarding. like
PrintWriter out = response.getWriter();
rd.forward(request, response); //this is good
rd.forward(request, response); //this throws an exception