Struts2 アプリケーションからファイルをダウンロードすると、ファイルのダウンロード後にセッションが期限切れになります。これは起こらないはずです。
setMaxInactiveInterval() を使用してセッション タイムアウトを設定できますが、ファイル サイズは一定ではなく、ダウンロード時間はファイル サイズなどによって異なります。
解決策を教えてください。
私のファイルダウンロードコードは次のとおりです。
InputStream fileInputStream = null;
File file = null;
String fileDir = "C:\\CAP\\FileDownload\\file\\";
String fileName = "SW.zip";
HttpSession sessio = null;
try {
sessio = request.getSession();
logger.debug("--------------->>>>"+sessio.getMaxInactiveInterval());
file = new File(fileDir+fileName);
logger.debug(":::::::::-->"+file.isFile());
fileInputStream = new FileInputStream(file);
ServletOutputStream outputStream = null;
response.addHeader("Content-Disposition", "attachment; filename="
+ fileName);
response.setContentLength((int) file.length());
outputStream = response.getOutputStream();
// Copy the contents of the file to the output stream
byte[] buf = new byte[1024];
int count = 0;
while ((count = fileInputStream.read(buf)) >= 0) {
outputStream.write(buf, 0, count);
logger.debug("Count Is : "+count);
}
logger.debug("====================compleated the file donlowding ====================");
} catch (IOException e) {
logger.error("ERROR while reading and wring file : "
+ e.getMessage());
}