JSP保存文件后页面跳转问题
private void doDown(HttpServletRequest req, HttpServletResponse res) throws
ServletException,
IOException {
RequestDispatcher rd = null;
HSSFWorkbook workBook = null;
try{
workBook = writeToExcelSonotaMH(req, list);
if (workBook == null) {
rd = req.getRequestDispatcher(SontaCommon.DOWNLOAD_JSP);
rd.forward(req, res);
} else {
String downloadFileName = Common.XLS;
res.reset();
res.setContentType( "application/x-msexcel;charset=Shift_JIS ");
res.setHeader( "Content-Disposition ", "attachment; filename=\ " "
+ CommonUtil.toUtf8String(downloadFileName)
+ "\ " "
);
workBook.write(res.getOutputStream());
}
rd = req.getRequestDispatcher(SontaCommon.DOWNLOAD_JSP);