You are right it doesnot throw an IllegalStateException.
I read that from the SCWCD Study Kit. Page 96, last paragraph says:
Both methods throw a java.lang.IllegalStateException if the response is already committed. Similarly, after calling these methods, the response should be assumed to be committed, and no other data should be written to the output stream.
BUT,
I tried this (modified example from SCWCD study kit chapter6) on
Tomcat and it did NOT ignore the output. ???
public void service(HttpServletRequest req, HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException
{
res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); PrintWriter pw = res.getWriter();
pw.println("<html>");
pw.println("<head>");
pw.println("</head>");
pw.println("<body>");
pw.println("Following are the application (or ServletContext) initialization parameters:<br>");
ServletContext context = getServletConfig().getServletContext();
Enumeration enum = context.getInitParameterNames();
while(enum.hasMoreElements())
{
String name = (String) enum.nextElement();
String val = context.getInitParameter(name);
pw.println(name+" = "+val+"<br>");
}
pw.println("</body>");
pw.println("</html>");
}