Hi to all, i wanna ask you a question about downloading files from
struts action. Actually i'm working on application that has some
jasperreports, where by default my action prints as PDF, and it works
fine, but now i'm trying to serve an excel file, so i'm using the next code:
byte[] arrStream =
reportObj.getXlsReportStream("/reports/repDetalleRecarg.jrxml", parameters);
ServletOutputStream out = servletResponseObj.getOutputStream();
servletResponseObj.setContentType("application/vnd.ms-excel");
out.write(arrStream);
out.flush();
out.close();
Where reportObj is an object from a class that i code to abstract the
report byte[] generation, so i obtain the byte array, then declare and
instantiate the object from ServletOutputStream to write the stream,
then i establish the content type to excel file and finally write the
stream, but the problem is that works, but in the browser it gives me
the option to download a file with extension .action, like
myAction!myMethod.action , not an excel file, so i have to download it,
change it's extension to open it.
The code used for pdf generation is almost equal and it works fine,is this:
byte[] arrStream =
reportObj.getPdfReportStream("/reports/repDetalleRecarg.jrxml", parameters);
ServletOutputStream out = servletResponseObj.getOutputStream();
servletResponseObj.setContentType("application/pdf");
out.write(arrStream);
out.flush();
out.close();
Thanks in advance
--
Oscar Calderon
JAVA Tutorials and How to's? Visit http://www.javahowto.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org