lokeshreport Posted July 28, 2009 Share Posted July 28, 2009 Hi...I want to generate report for my requirment.....Im using the list of data from JRBeanCollectionDataSource.... but the response has not comming from DataSource im getting only parameteres which i passed...not even error also... I submited code below please any one can suggest me out of this hurdel.... its an very urgent for me...thanks Code:protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub ReportForTest rft=new ReportForTest(); rft.generateReport(); List lists = rft.getLists(); Map parameters = new HashMap(); parameters.put("Title", "Immunization Report"); try { ServletOutputStream outstream=response.getOutputStream(); InputStream reportStream =getServletConfig().getServletContext().getResourceAsStream("/reports/Medicationjr.jasper"); JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(lists); JasperRunManager.runReportToPdfStream(reportStream, outstream, parameters, ds); response.setContentType("application/pdf"); outstream.flush(); outstream.close(); System.out.println("Done"); } catch(Exception e) { e.printStackTrace(); StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); e.printStackTrace(printWriter); response.setContentType("text/plain"); response.getOutputStream().print(stringWriter.toString()); } } Link to comment Share on other sites More sharing options...
ntraykov Posted July 28, 2009 Share Posted July 28, 2009 Yes I have the same problem. I have a well working program, which uses JasperReports. It uses JRBeanCollectionDataSource(List items); to populate the rows with data, but if I compile the .jrxml file either with JasperCompileManager.compileToFile() or with iReports I see only parameters populated without rows. Does anyone have had such a problem Link to comment Share on other sites More sharing options...
ntraykov Posted July 29, 2009 Share Posted July 29, 2009 I think you had forgotten to put <detail> element in your .jrxml file. Is it so? Link to comment Share on other sites More sharing options...
lokeshreport Posted July 31, 2009 Author Share Posted July 31, 2009 No im using all those..... That report is executed and generate while i run in main() method.... /tools/fckeditor/editor/images/smiley/msn/regular_smile.gif but while i execute from server the blank page will appear....you can see jrxml file Code: Link to comment Share on other sites More sharing options...
Teodor Danciu Posted August 14, 2009 Share Posted August 14, 2009 Hi, This is not a proper way to deliver PDF to the browsers. Some browsers want to know in advance how many bytes will be sent to them on the response stream.You should better take a look at the /demo/samples/webapp sample provided with the JR project and learn how to use the PdfServlet class from JR, or get some inspiration from its source code. I hope this helps.Teodor 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