在myeclipse里读出 iReport作的.jrxml pdf形式 发生错误
在myeclipse里读出 iReport作的.jrxml pdf形式 发生错误
这是我的jsp
<%@ page language= "java " import= "java.util.* " pageEncoding= "ISO-8859-1 "%>
<%@ page contentType = "application/pdf; charset = UTF-8 "%>
<%@ page import = "
net.sf.jasperreports.engine.* "%>
<%@ page import = "java.util.* "%>
<%@ page import = "java.io.* " %>
<%@ page import = "java.sql.* "%>
<html>
<head>
<title> MyiReport </title>
</head>
<body>
<%
Connection con = null;
try{
Class.forName( "con.mysql.jdbc.Driver ");
String url = "jdbc:mysql://localhost:3306/test ";
con = DriverManager.getConnection(url, "root ", "root ");
}catch(Exception ex){
ex.printStackTrace();
}
try{
con.setAutoCommit(false);
}catch(
SQLException ex1){
ex1.printStackTrace();
}
File reportFile = new File(application.getRealPath( "/WEB-INF/repotrs/test3.jrxml "));
Map <Object,Object> param = new HashMap <Object,Object> ();
param.put( "name ", new String( "apple "));
byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),param,con);
response.setContentType( "pdf ");
response.setContentLength(bytes.length);
try{
ServletOutputStream outs = response.getOutputStream();
outs.write(bytes,0,bytes.length);
outs.close();
con.close();
}catch(
FileNotFoundException ex){
ex.printStackTrace();
}catch(SQLException ex){
ex.printStackTrace();
}
%>
</body>
</html>
运行后提示错误:
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error: