About Question enthuware.jwpv6.2.1148 :
Posted: Sun Jul 16, 2017 12:35 pm
So to summarize, by the specification the following will 100% throw an IllegalStateException if the buffer is flushed before the call to the forward() method occurs
But in the opposite situation, The specification does not make it clear whether calling out.println() will throw an IllegalStateException if the response has been committed and it will just be ignored.
Code: Select all
out.println("<html><body>Page 1");
RequestDispatcher rd = request.getRequestDispatcher("SecondServlet"); rd.forward(request, response);
Code: Select all
RequestDispatcher rd = request.getRequestDispatcher("SecondServlet"); rd.forward(request, response);
out.println("Page 1<body><html>"); // let's say this is flushed automatically because the buffer size is very small :P