Hi,
I�m confused about when the response is commited and when the
IllegalStateException is throw.
The Spec says: "Calling flush() on the PrintWriter commits the response.", but the container doesn't throw any exception in the following code:
package beanPackage;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class SimpleServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.println("Servlet doGet Method put this content here!");
out.println("<br>before flush: "+resp.isCommitted());
out.flush();
resp.resetBuffer();
out.println("<br>after flush: "+resp.isCommitted());
}
}
I have the following result:
Servlet doGet Method put this content here!
before flush: false
The first isCommited() method returns correct boolean value(false), but if response is in commited state, the container shouldn't have to throw an IllegalStateException when I invoke response.resetBuffer() after flush() method?
Thanks in advanced.
Rodrigo
[ February 14, 2005: Message edited by: Rodrigo W Bonatto ]