I\'m implementing Server-Sent Events using Servlet 3.0\'s javax.servlet.AsyncContext interface.
However I can\'t understand how I should handle I/O errors like peer
There's an alternative solution, in cases where it's more convenient to use getWriter()
.
PrintWriter out = ac.getResponse().getWriter();
out.print(stuff);
out.flush(); // swallows IOException
if (out.checkError()) {
// handle error or throw out...
}
That is, the PrintWriter class does provide a method to retrieve write errors later.