源码
<%
out.print("Start<br/>");
try{
 File reportFile = new File(application.getRealPath("report/1.jasper"));
 Context initCtx = new InitialContext();
 Context ctx = (Context) initCtx.lookup("java:comp/env");
 Object obj = (Object) ctx.lookup("jdbc/test");
 javax.sql.DataSource ds = (javax.sql.DataSource)obj;
 Connection conn = ds.getConnection();
 Map parameters = new HashMap();
 parameters.put("Pname", "");
 byte[] bytes=JasperRunManager.runReportToPdf(reportFile.getPath(),parameters,conn);
     System.out.println("---------Jasper end-------------");
     response.setContentType("application/pdf");
     response.setContentLength(bytes.length);
     ServletOutputStream ouputStream = response.getOutputStream();
     ouputStream.write(bytes, 0, bytes.length);
     out.clear();
     out=pageContext.pushBody();
     conn.close();
  }catch(Exception ex){
                       out.print(ex.getMessage());
                       ex.printStackTrace();
}
%>
后台控制显示
JspEngine --> /test6.jsp
     ServletPath: /test6.jsp
        PathInfo: null
        RealPath: C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\Prj_2\test6.jsp
      RequestURI: /Prj_2/test6.jsp
     QueryString: null
  Request Params: 
Fill 6199956: created for classic
Fill 6199956: filling report
Fill 6199956: Creating sql query executer
SQL query string: select * from family
Fill 6199956: adding page 1
Fill 6199956: title
Fill 6199956: page header
Fill 6199956: column header
Fill 6199956: detail
Fill 6199956: detail
Fill 6199956: detail
Fill 6199956: detail
Fill 6199956: page footer
Fill 6199956: ended
Fill 6199956: closing query executer
---------Jasper end-------------web显示的什么东西都没有,大家帮忙看下啥????解决问题送100分,或者你有更好的源码可以发给我22624223@qq。com
还有,导出HTML的也有问题,不过目前害处留在PDF阶段,哈,给说下HTML也送分,谢谢各位,着急!!!!!!!!!

解决方案 »

  1.   

     response.setContentType("application/ms-word");
    导出word有内容吗?
    如果都没有,也没有报错
    可能是ireport设计报表的时候就有问题
     
      

  2.   

    加上试试:
    response.setHeader("Pragma","No-cache");
    response.setHeader("Cache-Control","no-cache");
    response.setDateHeader("Expires", 0);
    response.setContentType("application/pdf");
      

  3.   

    在ouputStream.write(bytes, 0, bytes.length); 下面加上:
    ouputStream.flush();
    ouputStream.close();
    这两句话,再出错的话,你检查下你的jrxml文件 
    给你邮箱里发了 相关资料 ,你看下
      

  4.   

    现在的情况是这样的,在Adobe render  出现有数据,程序也运行正常,但是,在WEB页面什么都不显示,不显示中文是我在做报表的时候没有改变原来的字体,但是为什么在加载的时候,WEB页面上不显示Adobe render 的界面呀呀,一片空白。
                谢谢各位的建议!!!