On 28/11/2012 20:34, Michael-O wrote: > Hi, > > I am having again trouble with the respone.sendError method. The docs > say that an IllegalStateException is thrown if response has already been > committed. So this should cause an exception: > > protected void doGet(HttpServletRequest request, HttpServletResponse > response) throws ServletException, IOException { > PrintWriter out = response.getWriter(); > out.println("ERROR"); > out.flush(); > response.sendError(404); > } > > The exception is thrown out to the console but the response is still > written. If I leave out the flush (which commits the response). The > error page comes up. > > Is this undefined behavior or some missing code path to transform the > ISE to a HTTP 500 error response?
Nope. Think about it. Once the response has been committed the response status line and the headers have been written to the client as well as at least some if not all of the response body. Tomcat can't take back the data it has already sent. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org