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
The problem is that: ac.getResponse.getWriter().flush()
does not throw IOException
So in order to get a error notification upon I/O operation you need to use ServletOutputStream
instead:
try {
ServletOutputStream out = ac.getResponse().getOutputStream();
out.print(stuff);
out.flush(); // throws IOException
}
catch(IOException e) {
// handle a error
}