Show blank PDF

0

Hello.

I checked D:\\report11121.pdf genereted success.

But report is showing blank PDF page.

What is the problem?

<?xml version="1.0" encoding="UTF-8" ?>
<%@page import="java.io.ByteArrayOutputStream"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.bequs.common.bean.PlusWorkConfig"%>
<%@page import="com.bequs.common.util.CommonUtil"%>
<%@page import="java.io.File"%>
<%@page import="java.io.OutputStream"%>
<%@page import="java.sql.*"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="net.sf.jasperreports.view.JasperViewer"%>
<%@page import="net.sf.jasperreports.engine.util.JRLoader"%>
<%@page import="net.sf.jasperreports.engine.*"%>
<%@page session="true" autoFlush="true" isErrorPage="false"%>
 
<%
    String reportPath = PlusWorkConfig.getWebAppPath() + "report/eq/equipMasterReport.jasper";
    String subReportPath1 = PlusWorkConfig.getWebAppPath() + "report/eq/equipMasterSubReport.jasper";
    String subReportPath2 = PlusWorkConfig.getWebAppPath() + "report/eq/equipMasterSubReport2.jasper";
    String subReportPath3 = PlusWorkConfig.getWebAppPath() + "report/eq/equipMasterSubReport3.jasper";
 
    //String destPath = PlusWorkConfig.getWebAppPath() +  "report/pdf/report21.pdf";
    String destPath = "D:\\report11121.pdf";
 
 String equipNoArray = request.getParameter("eqMstrCommonDTO.equipNo");
 String equipNo = equipNoArray.replaceAll("/", "','").substring(0,equipNoArray.replaceAll("/", "','").length()-1);
 
    File reportFile    = new File(reportPath);
 
    if(reportFile.exists() == false) throw new Exception("Report File Not Found"+ reportFile.getPath());
 
    Connection conn = null;
    OutputStream os = null;
 
    try{
        out.clear();
        out = pageContext.pushBody();
 
     String [] connConfig = CommonUtil.getConn();
 
     Class.forName("com.bequs.common.db.JndiObjectFactoryBeanUtil");
     conn = DriverManager.getConnection(connConfig[0], connConfig[1], connConfig[2]);
 
        JasperReportsContext jasperReportsContext = new SimpleJasperReportsContext();
        JasperReport jasperReport = (JasperReport)JRLoader.loadObject(jasperReportsContext,reportFile);
 
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("equipNo",equipNo);
        parameters.put("eqSubReport1",subReportPath1);
        parameters.put("eqSubReport2",subReportPath2);
        parameters.put("eqSubReport3",subReportPath3);
 
        JasperFillManager fillManager = JasperFillManager.getInstance(jasperReportsContext);
        //JasperPrint jasperPrint = fillManager.fill(jasperReport, parameters, conn);
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
 
        JasperExportManager exportManager = JasperExportManager.getInstance(jasperReportsContext);
        JasperExportManager.exportReportToPdfFile(jasperPrint, destPath);
        out.clear();
        out=pageContext.pushBody();
 
        response.setHeader("Cache-Control", "no-store");
        response.setHeader("Pragma", "no-cache");
        response.setDateHeader("Expires", 0);
       if(request.getProtocol().equals("HTTP/1.1")){
        response.setHeader("Cache-Control", "no-cache");
       }
 
       response.setHeader("Content-Disposition", "inline");
       response.setContentType("application/pdf");
 
       os = response.getOutputStream();
 
        JasperExportManager.exportReportToPdfStream(jasperPrint, os);
 
        os.flush();
 
    } catch(Exception e) {
       e.printStackTrace();
    } finally{
        if (conn != null) try { conn.close(); } catch(Exception x){}
        if (os != null) try { os.close(); } catch(Exception x){}
 
    }
%>

pochul2423's picture
Joined: May 29 2019 - 9:20pm
Last seen: 5 months 2 weeks ago

1 Answer:

0

Does the query of the report return some results? What is the "When No Data" type of the report? 

It's to few input to find the problem. 

regards

C-Box

C-Box's picture
2157
Joined: Jul 19 2006 - 5:58pm
Last seen: 1 day 21 hours ago
Feedback
randomness