jsp报表

<%

    File reportFile = new File(application.getRealPath("/ireport/xueji.jasper"));
    JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
    Map parameters = new HashMap();
    parameters.put("baiji", "c1");
   //parameters.put("BaseDir", reportFile.getParentFile());   
   //JRBeanArrayDataSource jrDataSource = new JRBeanArrayDataSource(objects);//objects为要打印的实体数组;
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/xueji","root","root");
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
         
    JRHtmlExporter exporter = new JRHtmlExporter();
    StringBuffer sbuffer = new StringBuffer();
    Map imagesMap = new HashMap();
    session.setAttribute("IMAGES_MAP", imagesMap);
   
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
    //exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
    //exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "/ireport/ireport_html.Image?image=");
    //exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "
");
    exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
    exporter.exportReport();
    //out.flush();
    conn.close();
   % >

你可能感兴趣的:(html,jsp,mysql,jdbc)