I am new to Spring MVC and trying to see if this is possible. So if I make a single request and this request takes about 1 minute to process before writing to the OutputStream from the HttpServletResponse object, then I make another request that only takes 15 seconds and writes to the OutputStream. Do each request share the same OutputStream? Currently I am getting an error and I am thinking its because the second request closes the OutputStream. This is the error "java.net.SocketException: Software caused connection abort: socket write error"
private static final String APPLICATION_EXCEL = "application/vnd.ms-excel";
@RequestMapping(value = "/a", method = RequestMethod.GET, produces = APPLICATION_EXCEL)
public @ResponseBody
void downloadA(HttpServletResponse response) throws IOException {
response.setContentType(APPLICATION_EXCEL);
response.setHeader("Content-Disposition", "attachment; filename=" + "a.xlsx");
HSSFWorkbook workbook1 = new HSSFWorkbook();
//long task...
ServletOutputStream outputStream = response.getOutputStream();
workbook1.write(outputStream);
workbook1.close();
}
@RequestMapping(value = "/b", method = RequestMethod.GET, produces = APPLICATION_EXCEL)
public @ResponseBody
void downloadB(HttpServletResponse response) throws IOException {
response.setContentType(APPLICATION_EXCEL);
response.setHeader("Content-Disposition", "attachment; filename=" + "b.xlsx");
HSSFWorkbook workbook1 = new HSSFWorkbook();
ServletOutputStream outputStream = response.getOutputStream();
workbook1.write(outputStream);
workbook1.close();
}