Streaming JasperReport to Apache Tomcat Server with OutputStream


I created a JasperReport  and saved the .jrxml at <reportLocation>. It was no problem to write a Java program which creates a PDF file from this report.

But now I want to write a Spring Boot Project to stream this report to a Tomcat Server, to show it in the browser.

But the output has the wrong format. It looks like this:


It should have HTML layout. How can I do that?

Another problem that I have is that if the report is to long, it doesn't fit in the outputStream and I get an Error.

This is my SpringBootApplication:

public class TestProject2Application {
    @RequestMapping(method = RequestMethod.GET)
    public void RepPerformance2(OutputStream outputStream) {
        // create a database connection
        MyOracleConnection conManager = new MyOracleConnection("jdbc:oracle:thin:@/...");
        Connection con = conManager.openConnection(...);
        // create the report
        // close database connection
    public static void main(String[] args) {, args);

This runs my JasperReport:

   private boolean runReport(String reportLocation, HashMap<String, Object> parameter, OutputStream outputStream) {
        parameter.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
        try {
            JasperReport jasperReport = JasperCompileManager.compileReport(reportLocation);
            JasperFillManager.fillReportToStream(jasperReport, outputStream, parameter, con);
        } catch (JRException ex) {
            return false;
        return true;

Thanks for your ideas,


RebeccaS.'s picture
Joined: Mar 10 2015 - 7:23am
Last seen: 8 years 4 weeks ago

0 Answers:

No answers yet