The exception message is clear:
Cannot submit an exception page : getOutputStream () has already been called for this answer
java.lang.IllegalStateException: getOutputStream () has already been called for this answer
on org.apache.catalina.connector.Response. getWriter (Response.java:610)
IOException , , servletcontainer , getWriter() . IOException , .
, IOException , . catch IOException API . throws .
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
FileObject fileObject = getItSomehow();
if (fileObject != null && fileObject.getBinData() != null) {
response.setHeader("Content-disposition", "attachment; filename=\"" + fileObject.getFilename() + "\"");
response.setContentType(fileObject.getFiletype());
response.setContentLength((int)fileObject.getFilesize().intValue());
response.getOutputStream().write(fileObject.getBinData());
} else {
}
}