-1

Im trying to integrate jasper community edition with java,

    RestClientConfiguration configuration = RestClientConfiguration.loadConfiguration("jasper.properties");
    configuration.setAcceptMimeType(MimeType.JSON).setContentMimeType(MimeType.JSON).setJrsVersion(JRSVersion.v6_0_0).setLogHttp(true);
    configuration.setRestrictedHttpMethods(true);
    configuration.setHandleErrors(false);
    configuration.setLogHttp(false);
    configuration.setLogHttpEntity(false);
    JasperserverRestClient client = new JasperserverRestClient(configuration);
    Session session = client.authenticate("jasperadmin", "jasperadmin");
    OperationResult<InputStream> result = client
            .authenticate("jasperadmin", "jasperadmin")
            .reportingService()
            .report("/reports/interactive/CustomersReport")
            .prepareForRun(ReportOutputFormat.HTML, 1)
            .run();
    InputStream report = result.getEntity();

Every thing is fine, im getting response as some Object, which i can save in file also, Now my question is i want to convert the InputStream to toString, so that i can get actual html content and i can print it in my jsp page,

I have tried this stackoverflow question but its not working for me, can any one help?

1 Answers1

0

Could you please try something like this:

Scanner s = new Scanner(report).useDelimiter("\\A");
String result = s.hasNext() ? s.next() : "";

or the options given in the link mentioned by you. After converting it into string try doing a sysout for the result.

System.out.println("Result: "+result);

Please let us know if you face any issue. Give us the errors when you try to print the result.

Shepherd
  • 320
  • 2
  • 16