H
Hikikomori
Hi all,
I am using Struts 1.2.4 and I have an Action that flushes a generated
excel file (Using Apache POI) to the client. The client is able to
download the file but an exception is thrown because the output stream
has been flushed. I am just wondering if there is a way to work around
this issue.
The code:
public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
.....
response.setContentType("application/x-download");
response.setHeader("Content-Disposition",
"attachment; filename=file.xls");
OutputStream out = response.getOutputStream();
// Generates the file
HSSFWorkbook wb = myService.makeExcel();
wb.write(out);
out.flush();
out.close();
// Can't forward after committing out stream. Exception thrown.
return mapping.findForward("forward.exportSuccess");
}
I am using Struts 1.2.4 and I have an Action that flushes a generated
excel file (Using Apache POI) to the client. The client is able to
download the file but an exception is thrown because the output stream
has been flushed. I am just wondering if there is a way to work around
this issue.
The code:
public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
.....
response.setContentType("application/x-download");
response.setHeader("Content-Disposition",
"attachment; filename=file.xls");
OutputStream out = response.getOutputStream();
// Generates the file
HSSFWorkbook wb = myService.makeExcel();
wb.write(out);
out.flush();
out.close();
// Can't forward after committing out stream. Exception thrown.
return mapping.findForward("forward.exportSuccess");
}