Unable to Include Images in the HTML file

0

007praveen

Hi All,
Iam working on the OC4j standalone server,I am working on struts
technology,where in my jsp i have an Export button when I click that
the following code is executed.

else if (searchUsersBean.getOrgFormat().equals(HTML)) {
/*JasperCompileManager.compileReportToFile(ConfigManager.getJasperReportXML());*/
File reportFile = new File(ConfigManager.getJasperReport());
if (!reportFile.exists())
throw ExceptionUtil.getCSMSException(new Exception(), 9);
JasperReport jasperReport = (JasperReport) JRLoader
..loadObject(reportFile.getPath());
Map parameters = new HashMap();
parameters.put(REPORT_TITLE, USER_REPORT);
parameters.put(BASE_DIR, reportFile.getParentFile());
parameters.put(IMAGE_PATH, ConfigManager.getAcpLogo());
request.getSession().setAttribute(R_PARAMETER, parameters);
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(
userList);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
parameters, ds);
JRHtmlExporter exporter = new JRHtmlExporter();
request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,
jasperPrint);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
PrintWriter out = response.getWriter();
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.exportReport();
}


The report is being executed but in the html file the images are not
properly included,Can any one help me out on this how to include the
images for an HTML format...



Thanks & Regards
Praveen Kumar.P
 
C

ck

/*JasperCompileManager.compileReportToFile(ConfigManager.getJasperReportXML());*/
File reportFile = new File(ConfigManager.getJasperReport());
if (!reportFile.exists())
throw ExceptionUtil.getCSMSException(new Exception(), 9);
JasperReport jasperReport = (JasperReport) JRLoader
.loadObject(reportFile.getPath());
Map parameters = new HashMap();
parameters.put(REPORT_TITLE, USER_REPORT);
parameters.put(BASE_DIR, reportFile.getParentFile());
parameters.put(IMAGE_PATH, ConfigManager.getAcpLogo());
request.getSession().setAttribute(R_PARAMETER, parameters);
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(
userList);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
parameters, ds);
JRHtmlExporter exporter = new JRHtmlExporter();
request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,
jasperPrint);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
PrintWriter out = response.getWriter();
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.exportReport();

Seems that you are using JasperReports, what is IMAGE_PATH? If html is
getting generated and only images are not getting rendered see what is
there in the img tag <img src="somepathAndImageName"> Make sure that
you have set it within the web app folder and does not point to some
path outside your web application folder.

Cheers,
Ck
http://www.gfour.net
 
L

Lew

Just a hint: format and indent posted code for readability.

Best practice: enclose all if, while, and for blocks in braces, even for only
one line.

- Lew
 
M

meghnagrover

Hi All,
Iam working on the OC4j standalone server,I am working on struts
technology,where in my jsp i have anExportbutton when I click that
the following code is executed.

else if (searchUsersBean.getOrgFormat().equals(HTML)) {
/*JasperCompileManager.compileReportToFile(ConfigManager.getJasperReportXML­());*/
File reportFile = new File(ConfigManager.getJasperReport());
if (!reportFile.exists())
throw ExceptionUtil.getCSMSException(new Exception(), 9);JasperReportjasperReport= (JasperReport) JRLoader
.loadObject(reportFile.getPath());
Map parameters = new HashMap();
parameters.put(REPORT_TITLE, USER_REPORT);
parameters.put(BASE_DIR, reportFile.getParentFile());
parameters.put(IMAGE_PATH, ConfigManager.getAcpLogo());
request.getSession().setAttribute(R_PARAMETER, parameters);
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(
userList);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
parameters, ds);
JRHtmlExporter exporter = new JRHtmlExporter();
request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION­_ATTRIBUTE,
jasperPrint);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
PrintWriter out = response.getWriter();
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.exportReport();

}

The report is being executed but in thehtmlfile the images are not
properly included,Can any one help me out on this how to include the
images for anHTMLformat...

Thanks & Regards
Praveen Kumar.P

Did you get the image problem working? I am getting a similar problem.
Any help would be appreciated.
Thanks,
meghna.
 
S

Sem

Did you get the image problem working? I am getting a similar problem.
Any help would be appreciated.
Thanks,
meghna.- Hide quoted text -

- Show quoted text -

Where did you insert the button image?
You have to call the image in the button where you declare.
And do not forget to put the path.

--sem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top