html export + image impossible




using jasperreports 4.8 with JDeveloper and weblogic I lost my mind over this, since I've done this sucessfully using jasperreports 3.7. with Jdeveloper and OAS, but now I simply cannot make it work. I've googled for hours and nothing helped me.
            /image (based on webapp demo - HtmlServlet, same goes for XhtmlServlet does not work)
            PrintWriter out = response.getWriter();
            File sourceFile = new File("/test.jasper");
            jReport = (JasperReport)JRLoader.loadObject(sourceFile);
            OracleConnection conn = getDBConnection("STRKZR");
            HashMap paramNameValues = new HashMap();
            jPrint = JasperFillManager.fillReport(jReport, paramNameValues, conn);
            JRHtmlExporter exporter = new JRHtmlExporter();
            request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jPrint);
            exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE); //regardless if this is true or false images do not show up
            exporter.setParameter(JRExporterParameter.JASPER_PRINT, jPrint);
            exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
            exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, ""); // hardcoded url to ImageServlet
When I look at the html source I can clearly see the src for image and it's correct:
I can copy paste the image src into new browser tab and it is displayed correctly. 
What could be the solution for this? Please help I'm out of ideas.
            request.getSession().setAttribute(net.sf.jasperreports.j2ee.servlets.ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jPrint);
            exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, response.getWriter());
            exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "../image?image="); //this is the line that was worng



thundric's picture
Joined: Feb 14 2008 - 10:37pm
Last seen: 5 years 11 months ago
Is realy exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE) required options to show images in html? It's very strange. P.S. I am use this options in all applications. But I'm very surprised
sanbez - 8 years 4 months ago
I've tried with and without exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE) and I can confirm that images are displayed correctly in both cases. This is not critical. My problem was only the line: exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"../image?image="); Just in case if someone wonders how to stop getting images from cache this can be used: exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"../image?"+ "time=" + System.currentTimeMillis() + "&image="); Hope it helps.
thundric - 8 years 4 months ago
Thanks for explanation. Im am knows about correct value parameter JRHtmlExporterParameter.IMAGES_URI = "image?image". But you found the solution before I see your question. With best regards. Alexander
sanbez - 8 years 4 months ago

0 Answers:

No answers yet