Question : How to integrate JasperReports with Tomcat ?

Hi All,
WE need a reporting web based tool for our database. I looked for open source reporting tools , like ireport and jasper reports, however so far could not find what we are looking for. Irreports is not web based, and Jasper Reports does not provide any piece of explanation on how to install and how to get it work. I searched google, but it didn't help. I thought this platform may have some help for us. I am looking forward to receiving some help from Experts.
Thanks in advance.
Regards :)
Yilmaz Ay

Some info about our paltform:
Os: Linux, Windows
Language: Java  (jdk1.4.1)
App.Ser: Tomcat 4x
DB : Mysql 4

Answer : How to integrate JasperReports with Tomcat ?

I used Tomcat 4.x and didn't do much that was super fancy. I imagine the tricks are fairly similar. Let me know where you are getting stuck as well as if you're just exporting to HTML or if you're using something else as well. Here's my brief outiline and a couple hints.

Fist: Start my creating your report and making it run generating your documents to files. If you aren't already familar with JR like I wasn't, this will make your life better.

Now you'll need to buid a servlet responsible for reading in whatever get/post parameters you pass in and setting up the report. I guess that's where it can get tricky.

One stumbling block I had was just finding the xml file to parse and worse, I had classpath issues when it went to compile the report. For finding it you might start by just using a hard coded file path and yanking it up, but that isn't really a long term portable solution. If the app is always going to be run on Tomcat, you could snag the catalina home property out of the system properties and use that as a reference point. The "right" option is probably to put the report in your classpath and load it as a resource using the class loader. I gather that the report can be precompiled but I didn't see how to do that. Instead I download BeanShell and used the JRBshCompiler to compile it on the fly for me.

I had a minor problem with the shaded elements in HTML. They used a tiny jpg which when I exported to a file was built on the fly. When I exported to a stream for integration into tomcat, that file went missing (and I think it was called something else). You'll need to export into a file to create it, and then just make sure that file is available in the same context as your servlet is running in. Although I didn't mess with it, I imagine this means you could use any image you wanted.

I don't have the code in front of me, so some of the nitty gritty changes I made I can't comment on. Give it a shot, it's pretty doable and when you get stuck, post here and I'll try to help.

Random Solutions  
 
programming4us programming4us