Blog How to integrate Pentaho (.prpt) reports with Java Web Application RSS Feed

How to integrate Pentaho (.prpt) reports with Java Web Application

Nov 15, 2016

In our earlier blog, we learned how to do Metadata injection using Pentaho. In today’s article, we’ll learn how to integrate Pentaho (.prpt) reports with a web application.

Typically, to generate reports, it requires working with Pentaho report designer and deploying “.prpt” file onto BI server. But what if we want to use Pentaho reports inside different types of web applications?

This article will serve as a tutorial to integrate your .prpt report with Java web application. You can apply different filters to report and pass parameters from JSP page, to generate the desired reports in different formats.

This article is written based on a real implementation of code and libraries. The only thing you need to consider before starting is to use the same versions of Pentaho SDK, Pentaho Reporting Engine, and Pentaho Report Designer, to avoid any issues related to a data source.

Here are the steps to follow to integrate a .prpt report with a java application:

1. Create “customer.prpt” file from Pentaho reports designer with necessary requirements.

Pentaho Report

2. Create dynamic web application from eclipse IDE or your choice of tool, and put “customer.prpt” report inside WebContent folder.

3. Create a JSP page with necessary parameters and submit the request to web Container.

Sample JSP:
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://190.166.7.11:3306/DB_NAME?user=root&password=root");
        Statement statement = connection.createStatement() ;
        resultset =statement.executeQuery("SELECT * FROM customers") ;
%>
<center>
        <select name="cname">  //parameter name associated with report
        <option value="-1"> – Select -</option> 
        <%  while(resultset.next()){ %>
            <option><%= resultset.getString("CUSTOMERNAME")%>
            </option>
        <% }
    }catch(Exception e){
        System.out.println("Exception"+e);
    }
       %>
        </select>            
</center>

JSP Pentaho Integration

Note: you can pass customer name from a database to find a match in a report. Parameter names in report and JSP page must be same.

4. Set the parameters into “ReportGeneraterClass” and fetch the desired data related to customer name.

Pentaho report 2

ReportGeneraterClass:  A Java class that contains code to read and write a report in different formats.

We hope that the above tutorial would help you to generate the required reports. For more details, please feel free to contact us.


Author:

This blog is written by TatvaSoft's Business Intelligence Solutions team. At TatvaSoft, we expertise in Pentaho Development and have catered to all the stacks offering state of the art solutions to our esteemed customers. Our portfolio incorporates industry-specific as well as technology specific solutions. Some of our experience includes the creation of, Data Integration process (custom ETL) and Enterprise Report generation; and Profiling of data using embedded Pentaho BI solution.

About Tatvasoft

TatvaSoft is a CMMi Level 3 and Microsoft Gold Certified Software Development Company offering custom software development services on diverse technology platforms, like Microsoft, SharePoint, Biztalk, Java, PHP, Open Source, BI, Big Data and Mobile.

Follow Us