I write file to OutputStream (got from response) in Spring controller. The file is large and I write in loops of 4 KB. When all finished, in finally block I flush and close output stream. If all goes fine it is good.
But in case there is error midway writing the file, how to show error to user?
In catch block I tried forwarding to error jsp, redirecting to error.jsp
, to html page, or writing in the OutputStream again like
outputstream.write('<html>...error happened...</html>'.getBytes())
But it allways shows OutputStream already obtained, or prev page stays in client side, and no way to show error. How to handle error in this case?