Jump to content
We've recently updated our Privacy Statement, available here ×

Streaming JasperReport to Apache Tomcat Server with OutputStream


RebeccaS.

Recommended Posts

Hi,

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:

output(5).png.61a341e2ba956e166b875d173fa72ce2.png

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:

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

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) {            System.out.println("JRException");            ex.printStackTrace();            return false;        }        virtualizer.cleanup();        return true;    }[/code]


Thanks for your ideas,

Rebecca

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...