I've following code in my servlet
public class RedirectingExceptionServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello, response is being committed");
out.flush();
response.sendRedirect("redirectedExceptionServlet");
System.out.println("Tried redirecting after committing response");
}
}
Here, I'm trying to redirect after the response has been committed.
As per the specification Send Redirect java doc sendRedirect(String) should throw IllegalStateException if you try to call sendRedirect(path) after response is committed
Rather i see a page with message : Hello, response is being committed
Another interesting thing is, i'm unable to see statement "Tried redirecting after committing response" in server console
Can someone pls explain me this behavior?
Env details : Windows 7, Tomcat 7.0.47, J2EE-6