JSP -> Servlet -> Jasper

Posted on 2006-04-11
Medium Priority
Last Modified: 2008-01-09
I have developed a report using Jasper. This report will be invoked from the JSP page which sends the requests to Servlet.

My question is how to i tell the servlet to run the Jasper report and send the report back to the user...

Please give me the process flow how to tackle this problem if anyone who has done this before.

I think this is very common requirement. The web page is allowed the user to run the report. Once the report is generated, the report is sent it back to the JSP page....

Question by:LeanMoreTryMore
  • 4
  • 3
LVL 16

Expert Comment

ID: 16433512
I think that you need to look at the Jasper documentation.

This worth to be looked at

LVL 16

Expert Comment

ID: 16433522

"Jasper report itself come with some nice samples and tutorials which are available in
and samples which are located in "Jasper report folder"\demo\samples"
taken from the URL above


Author Comment

ID: 16433658
I have read some documents.

I want to know how to invoke a jasper report from within Servlet and how to send it back to the user (JSP client)?

I think the attached link shows us how to build a jasper report but do not answer my question

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 16

Assisted Solution

suprapto45 earned 200 total points
ID: 16433828
Oh now I get you.

Try to read this link. It may be useful to you.

Look at the bottom messages


Accepted Solution

leogc earned 1400 total points
ID: 16434227
Compile the jasper report to get the .jasper file.Then in servlet u can write the following code to generate the report:
               JasperPrint jasperPrint = JasperFillManager.fillReport(jasperFileName,
                        parameters, new JRBeanArrayDataSource(beanName));

               byte[] bytes = JasperExportManager.exportReportToPdf(jasperPrint);
               String pdfFileName = strReportFileName + ".pdf";
                ServletOutputStream ouputStream = response.getOutputStream();
                response.setHeader("Expires", "");
                response.setHeader("Cache-Control", "");
                response.setHeader("Pragma", "");
                ouputStream.write(bytes, 0, bytes.length);
Note for compiling u r servlet u need to have the jar file provided by jasper reports.This approach uses JRBeanArrayDataSource.For this u should first create a bean with properties.These properties will be represented as columns of report.Compile u r bean.Make a jar.Using this jar and specifying u r field names in jasper as column names
compile u r jrxml file to get the jasper file.Pass the jasper file name to JasperFillManager.fillReport() as shown above.Then u will be able to generate the report.

Author Comment

ID: 16442523
Thanks for you guys

Is it the common way to be used in commerical web application? I means always use Servlet technology to generate Jasper report and send it back to web client.???

LVL 16

Expert Comment

ID: 16475050

>>"Is it the common way to be used in commerical web application?"
I am not sure but I think so. I can't find any other way to do it. Alternatively, you can create a custom tag for it and use this tag to display it into your JSP (that would be neater).


Author Comment

ID: 16523387
Would David give me a simple program to use tag to diaplay it into the JSP?


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question