I am using Jasper report 6. I'have been creating a report with an image. this image is located at my local drive. I try to call this report from my app project.The image doesn't appear when i'm running in app. but it appear in Jasper. How can I set the image path to appear at my applications root and not from my local drive?
I try to using parameter for the image like this, but it's still error :
if (message.equalsIgnoreCase("PrintAlasanPenolakan")) {
File reportFile = new File(getServletConfig().getServletContext().getRealPath("/WEB-INF/reports/reportListAlasanPenolakan.jasper"));
byte[] bytes = null;
try {
dataReportAlasanPenolakan = dbReportAlasanPenolakan.getAllAlasanPenolakanReport();
Map model = new HashMap();
model.put("user", (String) session.getAttribute("user_id"));
model.put ("Image", (String) this.getServletConfig().getServletContext().getRealPath("/WEB-INF/reports/logo.png"));
bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), model, new JRBeanCollectionDataSource(dataReportAlasanPenolakan));
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
servletOutputStream.write(bytes, 0, bytes.length);
servletOutputStream.flush();
servletOutputStream.close();
} catch (Exception e) {
log.info("Error Print PDF:" + e.getMessage());
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
response.setContentType("text/plain");
response.getOutputStream().print(stringWriter.toString());
} finally {
dbConn.closeConnection();
}
}