mimiekimm Posted March 12, 2017 Share Posted March 12, 2017 Hello everyone. I just encountered new problem. before this my jasper report is okay. but then i changed the directory of my file but moving my project into a new folder. sub-folder in my project. im using netbaens and using jsp. before this, there is no problem at all to generate the report, but then yesterday, after i did the moving all files, when i try to generate the report, it return error:null. i have check all libraries and everthing. im using jdk 7. my jasper report plug in is version 5.6.0 and it is the same as my jasperreport.jar 5.6.0. i have tested all the path at my path which something like this File reportFile = new File(application.getRealPath("..//reports//test.jasper")); i have tried so many time changed it to many possible path but is seems to get errorhere is the full coding to generate the report <%@page import="Config.Config"%><%@page import="dBConn.Conn"%><%@page import="java.io.*"%> <%@page import="java.sql.Connection"%> <%@page import="java.sql.DriverManager"%><%@page import="java.util.HashMap"%><%@page import="java.util.Map"%><%@page import="net.sf.jasperreports.engine.*"%><%@page import="main.RMIConnector"%><%@page import="java.util.ArrayList"%> <%@page contentType="text/html" pageEncoding="UTF-8"%><!DOCTYPE html><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <% try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://10.73.32.200:3306/emedica?zeroDateTimeBehavior=convertToNull", "root", "qwerty"); File reportFile = new File(application.getRealPath("..//reports//test.jasper")); Map map = new HashMap(); byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),map,conn); response.setContentType("application/pdf"); response.setContentLength(bytes.length); ServletOutputStream outStream = response.getOutputStream(); outStream.write(bytes, 0, bytes.length); outStream.flush(); outStream.close(); } catch (Exception ex) { out.println("Error: " + ex.getMessage()); } %> </body></html> i think my main problem is the path, anyone has idea?thanks Link to comment Share on other sites More sharing options...
mimiekimm Posted March 12, 2017 Author Share Posted March 12, 2017 seems like i need to get the 'reports' folder into web. problem solved Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now