67,513
社区成员
发帖
与我相关
我的任务
分享
Connection conn = null;
//加载驱动
Properties prop = new Properties();
InputStream inStream = PrintUtil.class.getClassLoader().getResourceAsStream("application.properties");//new FileInputStream("application.properties");
prop.load(inStream);
Class.forName(prop.getProperty("jdbc.driver"));
conn = DriverManager.getConnection(prop.getProperty("jdbc.url"),prop.getProperty("jdbc.username"),prop.getProperty("jdbc.password"));
prop.clear();
inStream.close();
String path = request.getSession().getServletContext().getRealPath("/ireports/"+"deliverynote.jasper");
JasperPrint jasperPrint=JasperFillManager.fillReport(path,parameters,conn);//填充报表数据生成JasperPrint对象
HttpServletResponse response = Struts2Utils.getResponse();
System.out.println("----------------------------------000000000000000");
response.setContentType("application/octet-stream");
ServletOutputStream ouputStream = (ServletOutputStream) response.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(ouputStream);
oos.writeObject(jasperPrint);//将JasperPrint对象写入对象输出流中
System.out.println("-----------44------");
oos.flush();
oos.close();
document.writeln('<APPLET CODE="net.sf.jasperreports.applets.PrinterApplet.class" NAME="printerApplet"'+
'CODEBASE="./" ARCHIVE="${ctx}/myeditor/applets/reportPrint.jar,${ctx}/myeditor/applets/commons-logging-1.1.1.jar" WIDTH="0" HEIGHT="0">'+
'<PARAM NAME="type" VALUE="application/x-java-applet;version=1.6.0">'+
'<PARAM NAME="scriptable" VALUE="false">'+
'<PARAM NAME="REPORT_URL" value="${ctx}/background/order!printdn.action?orderId='+oid+'">'+
'</APPLET>');