We are generating our reports using JasperReports 5.6.1, and allow exporting the same template to PDF or Powerpoint. When running locally, the PDF and PPTX file downloaded work perfectly. When we deploy to our servers PDF works fine, but PPTX files cannot be opened. When we run locally, it is deployed to tomcat, but when deployed to the server it is running on Websphere.
Things I tried and noticed:
x
type files I tried exporting to xlsx also, just to see what would happen, and it works fine with the same template.Here is the code for where we write the response:
if ("xlsx".equals(type)) {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".xlsx");
} else if ("pptx".equals(type)) {
response.setContentType("application/vnd.openxmlformats-officedocument.presentationml.presentation");
response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".pptx");
response.setCharacterEncoding("UTF-8");
} else {
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".pdf");
}
try (final ByteArrayOutputStream reportResult = reportsService.generateReport(
getDeal(userId, dealId, sessionStore),
getScenarioModel(userId, dealId, scenarioId, sessionStore), reportId, type)) {
configureResponse(response, type, reportResult, dealId + "-" + scenarioId);
// Write to http response
reportResult.writeTo(response.getOutputStream());
}
response.flushBuffer();
I have run out of ideas on troubleshooting steps, and without being able to reproduce it locally, I am finding it difficult to diagnose.
This is a bit of a shot in the dark, but are you sure that the mime type is correctly configured in your WebSphere instances? (I realize that setting the content type in the response should obviate the requirement for the web server to be configured for that MIME type, but it's WebSphere after all ;-))
I'm willing to bet that PDF is a configured MIME type but PPTX is not. Can you check?
(here's a more detailed technote)
IIRC, unlike Tomcat which is (for lack of a better term) kind of a "bundled" all-in-one http stack and servlet container, WebSphere has a separate http stack (along with a separate JVM for each app), so it's not surprising that configuration might be required there that would not be for simpler containers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With