error : null when run in website

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 error

here is the full coding to generate the report

<%@page import="Config.Config"%>
<%@page import="dBConn.Conn"%>
<%@page import="*"%> 
<%@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>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
            try {
                Connection conn = DriverManager.getConnection("jdbc:mysql://", "root", "qwerty");
                File reportFile = new File(application.getRealPath("..//reports//test.jasper"));
                Map map = new HashMap();
                byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),map,conn);
                ServletOutputStream outStream = response.getOutputStream();
                outStream.write(bytes, 0, bytes.length);
            } catch (Exception ex) {
                out.println("Error: " + ex.getMessage());
i think my main problem is the path, anyone has idea?


mimiekimm's picture
Joined: Jan 26 2017 - 6:56pm
Last seen: 6 years 1 week ago

seems like i need to get the 'reports' folder into web. problem solved 

mimiekimm - 6 years 2 weeks ago

0 Answers:

No answers yet