[jboss-user] [JBoss Seam] - changing response headers to modify filename for excel

pdhaigh do-not-reply at jboss.com
Thu Dec 13 13:18:52 EST 2007


Hi,

I'm trying to open a report in Excel, with a specified dynamic filename

I have an xhtml page that spits out simple tabulated data. On viewing that page ID I call a method from pages.xml that does this:

String fileName="Charity_Report"+i+".xls";
  |     		
  | HttpServletResponse response = (HttpServletResponse)ctx.getExternalContext().getResponse();
  | response.setContentType("application/vnd.ms-excel");
  | response.setHeader("Content-Disposition","attachment;filename=\"" + fileName + "\""); 
  | ctx.renderResponse();

This works... the report is generated correctly, and with the right filename etc. However, intermittently, the spreadsheet that opens will have both the report that just ran, and the previous one in it! (I should mention there are several different report pages, with different filenames - set up exactly the same as above).

It appears perhaps the response is not closing or something like that??

I tried this:

// TODO This is such a hack it's untrue (closes response after 5s)
  | maintenanceTasks.endResponse(5000L,ctx);

but although it doesn't seem to do any harm, it doesn't fix the intermittent problem.

any ideas?

cheers

phil

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112672#4112672

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4112672



More information about the jboss-user mailing list