report.java什麼和得到錯誤空指針錯誤碧玉報告顯示的NetBeans
byte[] pdfbyte = null;
try {
dbcon connect = new dbcon();
ServletContext context = this.getServletConfig().getServletContext();
String compiledFileName = context.getRealPath("/jasper/report3.jasper");
System.out.print(compiledFileName);
// String var = request.getParameter("var").toString();
//String res = JOptionPane.showInputDialog(null, "What is your name?", "Enter your name",JOptionPane.QUESTION_MESSAGE);
File reportFile = new File(compiledFileName);
HashMap parameters = new HashMap();
// // parameters.put("itemName", var);
parameters.put("ReportTitle", "MyReport");
// parameters.put("BaseDir", reportFile.getParentFile());
// parameters.put("EmpNo", 32504);
JasperPrint jasperPrint = null;
Connection conn = connect.dbstate().getConnection();
try {
try {
jasperPrint = JasperFillManager.fillReport(compiledFileName, parameters, conn);
pdfbyte = JasperExportManager.exportReportToPdf(jasperPrint);
} catch (Exception e) {
System.out.print("E" + e);
}
} catch (Exception ex) {
System.out.println("*** Could not create compiled jasper file: " + ex.getMessage());
} finally {
try {
connect.dbstate().close();
} catch (SQLException ex) {
System.out.println("could not close databse after filling the report ");
}
}
ServletOutputStream outstream = response.getOutputStream();
response.setContentType("application/pdf");
response.setContentLength(pdfbyte.length);
response.setHeader("Content-disposition", "inline; filename=\"Report.pdf\"");
outstream.write(pdfbyte);
} catch (Exception e) {
System.out.print(e);
e.printStackTrace();
}
圖書館
我得到的NetBeans
SEVERE: A web application registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Ejava.lang.NullPointerExceptionjava.lang.NullPointerExceptionjava.lang.NullPointerException
at jasper.Report.processRequest(Report.java:63)
at jasper.Report.doGet(Report.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at java.lang.Thread.run(Thread.java:619)
以下錯誤
該報告是在'pdfFilePath'生成的嗎? - 另外,個人而言,我會避免在運行時編譯報告,因爲這是一個相當緩慢的過程,您應該能夠預編譯,然後只需使用輸出來填充報告... – MadProgrammer
是的..我想要下載/生成報告到服務器文件夾'jasperReport'並且瀏覽器上應該顯示相同的時間報告。 – Ravi
您可以將報告輸出到HTML並將結果輸出到服務器。否則,你應該嘗試提供鏈接...我想,自從我嘗試過這樣的事情之後,我有一段時間了) – MadProgrammer