thundric Posted December 5, 2012 Share Posted December 5, 2012 Hi, using jasperreports 4.8 with JDeveloper 11.1.1.5 and weblogic 10.3.5.0 I lost my mind over this, since I've done this sucessfully using jasperreports 3.7. with Jdeveloper 10.1.3.4 and OAS 10.1.3.4.1, but now I simply cannot make it work. I've googled for hours and nothing helped me. web.xml ImageServlet net.sf.jasperreports.j2ee.servlets.ImageServlet ImageServlet /image servlet.java (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, "http://127.0.0.1:7101/Portal-ViewController-context-root/faces/image?image="); // hardcoded url to ImageServlet exporter.exportReport(); When I look at the html source I can clearly see the src for image and it's correct: img src="http://127.0.0.1:7101/Portal-ViewController-context-root/faces/image?image=img_0_0_1" style="height: 49px" alt="" 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. Solved: request.getSession().setAttribute(net.sf.jasperreports.j2ee.servlets.ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jPrint); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jPrint); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, response.getWriter()); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "../image?image="); //this is the line that was worng exporter.exportReport(); Link to comment Share on other sites More sharing options...
sanbez Posted December 5, 2012 Share Posted December 5, 2012 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 Link to comment Share on other sites More sharing options...
thundric Posted December 5, 2012 Author Share Posted December 5, 2012 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. Link to comment Share on other sites More sharing options...
sanbez Posted December 5, 2012 Share Posted December 5, 2012 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 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