File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes file .jasper and jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "file .jasper and jsp" Watch "file .jasper and jsp" New topic

file .jasper and jsp

jaime cruz

Joined: Feb 04, 2004
Posts: 1
I am attempt to print a report.jasper from jsp file but it is print a blank page
below is the code. can anybody help me? Please

<%//@ page errorPage="error.jsp" %>
<%//@ page import="datasource.*" %>
<%@ page import="dori.jasper.engine.*" %>
<%@ page import="java.util.*" %>
<%@ page import="*" %>
<%@ page import="*"%>
<%@ page import="dori.jasper.engine.export.*"%>
<%@ page import="dori.jasper.engine.util.*"%>
<%@ page import="dori.jasper.view.*"%>
<%@ page import="java.sql.*"%>
<%@ include file="coneccion.jsp"

Driver d = (Driver)Class.forName(DBDriver).newInstance();
Connection conn = null;
conn = DriverManager.getConnection(strConn,DBusername,DBpassword);
//String driver = "oracle.jdbc.driver.OracleDriver";
//String connectString = "jdbc racle:thin:@dbserver:1521 rcl";
//String user = "hpdemo";String password = "hpdemo";
//Connection conn = DriverManager.getConnection(connectString, user, password);
File reportFile = new File(application.getRealPath("/reporte10.jasper"));
String path = reportFile.getAbsolutePath(); //tried getAbsolutePath()
//System.out.println("Absolute Path = " + reportFile.getAbsolutePath());
Map parameters = new HashMap();
parameters.put("myparam",new Integer(2));
parameters.put("ReportTitle", "Address Report");
parameters.put("BaseDir", reportFile.getParentFile());
JasperPrint jasperPrint = JasperManager.fillReport ( path,parameters, conn);
byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, conn);
JRPdfExporter exporter = new JRPdfExporter();
ByteArrayOutputStream pdfReport = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, pdfReport);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE, application.getRealPath("/Centros2/reporte10.jasper"));
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "reporte10.pdf");
bytes = pdfReport.toByteArray();
OutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
}catch(Exception e)

Joined: Jul 11, 2002
Posts: 1
I think the pdf page is saved in your web directory
I agree. Here's the link:
subject: file .jasper and jsp
It's not a secret anymore!