当前位置: 代码迷 >> Java Web开发 >> 在myeclipse里读出 iReport作的.jrxml pdf形式 发生异常
  详细解决方案

在myeclipse里读出 iReport作的.jrxml pdf形式 发生异常

热度:47   发布时间:2016-04-17 14:14:08.0
在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);
  相关解决方案