Jump to content
We've recently updated our Privacy Statement, available here ×

JRBeanCollectionDataSource(List list) how..?


lokeshreport

Recommended Posts

 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

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

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

 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

  • 2 weeks later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...