• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Generate Charts with JasperReport

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm new to JasperReport. I'm now making use of JasperReport in a Servlet to generate a chart with data from an external DataSource(say from Oracle). I also use iReport to design my report.

I have found out two approaches to generate charts:
1. i. Query the database in the Servlet, generate the chart and render into an java.awt.Image object.
ii. Define a parameter of type java.awt.Image. Create an Image object in the report template and set its image expression as the parameter defined previously.
iii. Pass the image created in the Servlet as parameter to the report.

2. i. Define the database query in iReport.
ii. Create a Chart object in the report template. Set the data series of the Chart object to be the Report Fields generated by the query.
iii. Include the scriptlet class generated by iReport in the webapp.

Which approach is better? Thanks in advance!
 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your second approch is better thru iReport.
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

is there a better way then including the scriptlet in the webapp? i cant rebuild my project every time, if a chart has changed. to put it in the classpath dont work, the classloader of the webapp dont find the scriptlet this way.

thanks!
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic