当我通过jsp打印报告时出现问题。
首先,我认为它更像是内存错误,即NetBeans的 permgen 空间,但是当您部署应用程序并且它变为活动状态时它不应该发生,但问题仍然存在。
报告打印对于前 6-7 个报告工作正常,然后应用程序变得无响应并使其再次工作,我必须停止Apache并再次运行应用程序
这是我用来通过jsp打印报告的代码
try {
JasperReport jasperReport;
JasperPrint jasperPrint;
JasperDesign jasperdesign;
String path = getServletContext().getRealPath("/reports/admissionReport.jrxml");
String imagepath = getServletContext().getRealPath("/images//");
String imageSubPath = File.separatorChar + "";
imagepath = imagepath + imageSubPath;
jasperdesign = JRXmlLoader.load(path);
jasperReport = JasperCompileManager.compileReport(jasperdesign);
Connection con = this.getServiceFactory().getReportService().getDao().getJdbcTemplate().getDataSource().getConnection();
paramMap.put("imagePath", imagepath);
jasperPrint = JasperFillManager.fillReport(jasperReport, paramMap, con);
JasperExportManager.exportReportToPdfFile(jasperPrint, getServletContext().getRealPath("/reports/admissionReport.pdf"));
String filename = getServletContext().getRealPath("/reports/admissionReport.pdf");
File rtf = new File(filename);
int readBytes = 0;
response.setContentType("application/pdf");
response.setHeader("Cache-Control", "max-age=30");
response.setHeader("Content-disposition", "inline; filename=\"admissionReport\"");
response.setContentLength((int) rtf.length());
input = new FileInputStream(rtf);
BufferedInputStream buf = new BufferedInputStream(input);
OutputStream stream = response.getOutputStream();
while ((readBytes = buf.read()) != -1) {
stream.write(readBytes);
}
stream.flush();
stream.close();
} catch (Exception exp) {
throw new Exception("Error occured while saving record.." + exp.getMessage());
} finally {
if (input != null) {
input.close();
}
}
到目前为止,我无法通过互联网找到解决方案。
PS我正在使用Spring框架进行开发。
我想知道是否有人可以解决这个问题。