在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:
[javac] Compiling 1 source file
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\test\org\apache\jsp\test3_jsp.java:84: 无法将 javax.servlet.jsp.PageContext 中的 handlePageException(java.lang.Exception) 应用于 (java.lang.Throwable)
if (pageContext != null) pageContext.handlePageException(t);
^
1 错误
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
帮忙看一下吧 哪里出错了 谢谢了
还有就是iReport生成的是jrxml文件阿 可是为什么有些地方提到jasper文件 怎么个情况阿
[解决办法]
ireport 编译一下就可以生成.jasper的文件,然后去读.jasper的文件就可以了,我正在研究,我差一点就成功了,我还差iTextAsian.jar这个亚洲字符包没有搞定,在网上找不到,能找到的都是iTextAsian.zip格式的,导致我输出的pdf都是乱码。你有这个语言包(iTextAsian.jar)码?咱们可以交流一下。
--------------------------------
File reportFile = new File(application.getRealPath( "/WEB-INF/repotrs/test3.jrxml "));
这一句,你把ireport 编译后的文件test3.jasper 放到WEB-INF/repotrs/下,然后改成
File reportFile = new File(application.getRealPath( "/WEB-INF/repotrs/test3.jasper "));
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html