2004 IR Help Posted August 21, 2006 Share Posted August 21, 2006 By: ilmagowalter - ilmagowalter jasper e struts 2005-05-09 02:03 Hello to all. It succeeds this to me: job with struts and jasper; in the file struts-config.xml I have made the forward file pdf that I create with jasper; if launch action that it creates the report through link HTML the action comes executed two times and the report it is opened in the browser; if launch the action through the submit of a form (I must pass parameters) the action comes executed once but it does not come visualized file pdf in the browser. Can to help me? thanks By: adu - actvolcano RE: jasper e struts 2005-05-09 02:41 I have encounted this problem before, maybe it was caused by the parameters you passed. By: ilmagowalter - ilmagowalter RE: jasper e struts 2005-05-09 03:28 How you have resolved? By: Ionut Nedelcu - ionutned RE: jasper e struts 2005-05-09 04:39 I believe a more elegant and less buggy solution is to create a servlet that returns the PDF content directly. Look at the "webapp" sample for a detailed example, there is a PdfServlet.java that shows you how to send PDF content from the servlet (or any other format you choose). By: adu - actvolcano RE: jasper e struts 2005-05-09 04:46 I have put the parameters into session, then the jsp file much like this: <%@ page import="net.sf.jasperreports.engine.*" %> <%@ page import="net.sf.jasperreports.engine.export.*"%> <%@ page import="net.sf.jasperreports.engine.util.*"%> <%@ page import="java.util.*" %> <%@ page import="java.io.*" %> <%@ page import="java.sql.*" %> <% File reportFile = new File(application.getRealPath("/reports/test.jasper")); Map parameters = new HashMap(); String param = (String)request.getSession().getAttribute("param1"); parameters.put("stuffid",param); Connection conn = null; Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String url="jdbc:oracle:thin:@192.168.0.200:1521:xxxx"; String user="xxxx"; String password="xxxx"; conn = DriverManager.getConnection(url,user,password); byte bytes[] = JasperRunManager.runReportToPdf(reportFile.getPath(),parameters,conn); response.setContentType("application/pdf"); //response.setHeader("Content-disposition","attachment; filename=test.pdf" ); response.setContentLength(bytes.length); ServletOutputStream ouputStream = response.getOutputStream(); ouputStream.write(bytes, 0, bytes.length); ouputStream.flush(); ouputStream.close(); %> By: ilmagowalter - ilmagowalter RE: jasper e struts 2005-05-09 06:16 I cannot make elaborations on jsp; you have an example working with struts? please it is urgent Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now