I was just wondering why JasperViewer only works on localhost. When I deployed my project to server, clients can not be able to view the reports anymore.
String reportDir = getServletContext().getRealPath("WEB-INF/classes/com/proj/reports");
String fileName = reportDir + "\\" + request.getParameter("reportName") + ".jasper";
File outReportDir = new File("C:/REPORTS_FOLDER");
outReportDir.mkdir();
long millis = System.currentTimeMillis();
String outFileName = outReportDir + "\\" + request.getParameter("reportName") + "_" + millis + ".pdf";
HashMap parameters = new HashMap();
parameters.put("P_BOOKING_MONTH", request.getParameter("selMonth"));
parameters.put("P_BOOKING_YR", request.getParameter("selYear"));
try {
Connection conn = ConnectionUtil.getConnection();
JasperPrint print = JasperFillManager.fillReport(fileName, parameters, conn);
JRExporter exporter = new net.sf.jasperreports.engine.export.JRPdfExporter();
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outFileName);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.exportReport();
JasperViewer.viewReport(print, false); }...