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.

Want to Hire Skilled Developers


    Comments

    • Leave a message...

    Related Articles
    Java lambda Expression
    Java Lambda Expression
    Jan 25, 2021
    Top 10 Java 10 Feature Listing
    Jan 25, 2021
    Is AWS Lambda a Server-Side Component?
    Jul 10, 2020