RebeccaS. Posted July 21, 2015 Share Posted July 21, 2015 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: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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now