emmadi Posted October 16, 2008 Share Posted October 16, 2008 Hi i am trying to generate a pdf report by passing groupname to the jrxml file here i am using pdf.jsp to pass the valueString groupname =request.getParameter("groupname");String file = request.getParameter("jr"); String fileloc = file+".jrxml"; System.out.println("filelocation-->"+fileloc); HashMap parameter = new HashMap(); JasperPrint jasperPrint = null; Connection connection = null; // parameter.put("gname",groupname); parameter.put("gname","employee"); File reportFile=new File(application.getRealPath(fileloc)); JasperDesign jasperDesign=JRXmlLoader.load(reportFile.getPath()); JasperReport jasperReport=JasperCompileManager.compileReport(jasperDesign); String dbproperties=application.getRealPath("Database"); FileInputStream fis=new FileInputStream(dbproperties); Properties props=new Properties(); props.load(fis); String driver=props.getProperty("driver"); String url="jdbc:mysql://localhost/harika" ; String username="root" ; String password="touch" ; Class.forName(driver); Connection jdbcConnection=DriverManager.getConnection(url,username,password); byte[] bytes=JasperRunManager.runReportToPdf(jasperReport,null,jdbcConnection); response.setContentType("application/pdf"); ServletOutputStream outputStream=response.getOutputStream(); outputStream.write(bytes,0,bytes.length); outputStream.flush(); outputStream.close(); }catch(Exception e) {out.println(e); } %> </body> </html> and modifications done in jrxml are <parameter name="gname" isForPrompting="false" class="java.lang.String"/> <queryString><![CDATA[select * from user_account where groupname=$P{gname}]]></queryString> but i dint get any errors while i am compiling but there is no resulti am getting a blank pdf reportPlease some body help methanku Link to comment Share on other sites More sharing options...
weeralalith Posted October 16, 2008 Share Posted October 16, 2008 you have to do 2 modifications1. <parameter name="gname" isForPrompting="false" class="java.lang.String" />Change the above line as <parameter name="gname" isForPrompting="true" class="java.lang.String" />2. byte[] bytes=JasperRunManager.runReportToPdf(jasperReport,null,jdbcConnection);Change the above line as byte[] bytes=JasperRunManager.runReportToPdf(jasperReport, parameter,jdbcConnection); Link to comment Share on other sites More sharing options...
emmadi Posted October 21, 2008 Author Share Posted October 21, 2008 Thanku very much i got the report 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