我面临一个 servlet 的问题,该 servlet 生成一个用 POI 创建的大 excel 文件。这个 servlet 执行类似下面的代码:
// (...)
// set headers and names
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename="
+ fileName + ".xlsx");
workbook = new SXSSFWorkbook(flushLimit);
workbook.setCompressTempFiles(true);
while (resultSet.next()) {
// add rows and cell to excel file
//(...) about 3000000 rows
}
logger.info("Writing and closing to temp file");
workbook.write(fileOutputStream);
logger.info("Dispose Workbook");
workbook.dispose();
logger.info("Closing fileOutputStream");
IOUtils.closeQuietly(fileOutputStream);
logger.info("Passing file to servlet outputstream");
fileInputStream=new FileInputStream(tempFileOutput);
IOUtils.copy(fileInputStream, response.getOutputStream());
logger.info("Closing fileInputStream");
IOUtils.closeQuietly(fileInputStream);
// delete temporal file
try {
tempFileOutput.delete();
} catch (Exception e) {
logger.error("Error trying to delete file");
}
// close servlet
response.getOutputStream().flush();
response.getOutputStream().close();
当 servlet 生成报告的时间超过 10 分钟且文件大小约为 100mb 时,它有时会显示网页显示内部问题(没有更多信息),或者在其他情况下页面仍在加载。尽管如此,excel文件生成正确,但传输被取消。
是否有配置阻止 OAS 中止连接?