源码
<%
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也送分,谢谢各位,着急!!!!!!!!!
<%
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也送分,谢谢各位,着急!!!!!!!!!
解决方案 »
- java.sql.SQLException: Io 异常: The Network Adapter could not establish the connec
- fusionchart数据显示问题
- 计算从我的页面做入口 进入其他站点的次数
- 在原系统接struts+hibernate+spring的问题
- jdbc连接sql,没成功过!!急!!!
- 请问用JSP怎么把网页做成像软件打开的样子
- 编译出错!!!!must be caught or declared to be thrown请帮忙看看!!!
- php程序员想转为Jsp程序员,请大家支持,帮我~~
- CSDN论坛助手 重出江湖!!!!爽!爽!!爽!!知道什么是极速吗?快来体验一下了。[周一早8:00发布]
- Struts2- ajax json 日期字符串注入Date
- jsp 下执行 sql 查询数组
- 奇怪的系统有时可登陆,有时候登陆不了的问题求高手。
导出word有内容吗?
如果都没有,也没有报错
可能是ireport设计报表的时候就有问题
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("application/pdf");
ouputStream.flush();
ouputStream.close();
这两句话,再出错的话,你检查下你的jrxml文件
给你邮箱里发了 相关资料 ,你看下
谢谢各位的建议!!!