No livro use a cabeca tem uma questão que pergunta quando é gerado a excpetion quando a resposta ja foi enviada.
A resposta é: write e flush.
No exame final tem uma questão parecida:
Given this fragment from a valid doGet() method:
12. OutputStream os = response.getOutputStream();
13. byte[] ba = {1,2,3};
14. os.write(ba);
15. RequestDispatcher rd = request.RequestDispatcher("my.jsp");
16. rd.forward(request, response);
Assuming that "my.jsp" adds the bytes 4, 5, and 6 to the response, what is the result?
A. 123
B. 456
C. 123456
D. 456123
E. An exception is thrown
Para mim isso dava exception pq ele usa o write.
Só que a resposta ele diz o seguinte:
-Option B: because os.flush() wasn?t called, the uncommitted output (123), is cleared, and forward is invoked without exception. If os.flush() had been called before forward, an IllegalStateException would have been thrown
O próprio livro se contradiz em suas páginas, alguém sabe se write causa ou não a excpetion?
qual ta certa?
valeu flw
