aspose file tools*
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
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "file .jasper and jsp" Watch "file .jasper and jsp" New topic
Author

file .jasper and jsp

jaime cruz
Greenhorn

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="java.io.*" %>
<%@ page import="dori.jasper.engine.data.*"%>
<%@ page import="dori.jasper.engine.export.*"%>
<%@ page import="dori.jasper.engine.util.*"%>
<%@ page import="dori.jasper.view.*"%>
<%@ page import="java.sql.*"%>
<%=application.getRealPath("/reporte10.jasper")%>
<%@ include file="coneccion.jsp"
%>

<%
try
{
Driver d = (Driver)Class.forName(DBDriver).newInstance();
Connection conn = null;
conn = DriverManager.getConnection(strConn,DBusername,DBpassword);
//String driver = "oracle.jdbc.driver.OracleDriver";
//Class.forName(driver);
//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");
exporter.exportReport();
bytes = pdfReport.toByteArray();
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
OutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
}catch(Exception e)
{e.printStackTrace();
}%>
Kithsiri
Greenhorn

Joined: Jul 11, 2002
Posts: 1
I think the pdf page is saved in your web directory
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: file .jasper and jsp