hello experts,

I want to show .jrxml file in html div as a preview of created report.

I am using eclipse luna and I was created a report in jasper soft studio 6.0. and i need to show this jrxml file in html <div> </div>
So please help me.

thank you.

Dani AI

Generated

As an expert summary for (and following ’s iframe suggestion): don’t try to show the raw .jrxml XML in a page. The robust pattern is compile the JRXML on the server, fill it with data/parameters, export to HTML, and deliver that HTML into the page (AJAX inject or a servlet endpoint). That keeps images, styles and resource handling under server control and avoids exposing design source. (javadoc.io)

Minimal servlet/JSP workflow (compile → fill → export to HTML and stream to the response). Example outline:

InputStream jrxml = getServletContext().getResourceAsStream("/WEB-INF/reports/myreport.jrxml");
JasperReport jasperReport = JasperCompileManager.compileReport(jrxml);

Map<String,Object> params = new HashMap<>();
// params.put("...");

JRDataSource ds = new JRBeanCollectionDataSource(dataList);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, ds);

HtmlExporter exporter = new HtmlExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
SimpleHtmlExporterOutput output = new SimpleHtmlExporterOutput(response.getWriter());
// optional: output.setImageHandler(new WebHtmlResourceHandler(request.getContextPath()+"/image?image={0}"));
exporter.setExporterOutput(output);
exporter.exportReport();

The modern HtmlExporter + SimpleHtmlExporterOutput pattern lets the servlet stream HTML directly; images can be routed through an image servlet or a WebHtmlResourceHandler so <img> src is served by the webapp (else the exporter writes an images folder). (javadoc.io)

Answering the follow-ups: show/hide fields — use a report parameter plus a Print When Expression (set on the textField/staticText/report element) so the element prints only when the parameter condition is true. Pass that parameter from the JSP/servlet into the fill call (Map<String,Object>). For replacing static text at runtime, use report parameters (or a resourceBundle) instead of hard-coded staticText; that lets the JSP set the values before fill. (community.jaspersoft.com)

Notes/cautions: don’t embed local file system paths in browser HTML (use servlet URLs), ensure image handlers and IMAGES_URI are configured if the HTML exporter writes separate files, and avoid exposing raw JRXML to end users for security. (infosys.ars.usda.gov)

Recommended Answers

All 4 Replies

When you create pdf report you can try to show it in iFrame.
There is conversation on this link, I hope this will help you. Mike.

hello mike

No i was created a html report and when i used i-frrame like:

<iframe src="E://abc.html" seamless></iframe>

Then output is
"The Address wasn't understood."

My problem is solved.

hello mike

I have problems with jasper report.

1] How to show and hide report fields using javascript function or servlet?

2] how to fetch static fields text in from jsp and display in textbox?

Please tell me with example of both questions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.