spmkkmps Posted July 14, 2009 Share Posted July 14, 2009 Hi,In my jrxml i have a String parameter named "imageFile" to display image in jasper reports. How to set image to this parameter from a java file. My web application structure is, inside /src/jasper(packagename)/my java files, and jasper file in the root folder. Also tell me where i need to put the image file. Its very urgent. Please post your replies immediately. Thanks a lot.Madhan Link to comment Share on other sites More sharing options...
spmkkmps Posted July 20, 2009 Author Share Posted July 20, 2009 Hi,For image display when exporting to html, in many sample code these code has been included. can anyone explain me, what for the below code is added. Map imagesMap=new HashMap();request.getSession().setAttribute("IMAGES_MAP",imagesMap);htmlExporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP,imagesMap);htmlExporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"image?image="); and what is this image?image=whether i need to type something after image= in the fourth statement and why do we need a map object without adding anything to it. Also please tell me, in jrxml what needs to be done to include image. Please post your replies as soon as possible. If you have the jrxml and java code for image display please attach it too. Its very urgent. Thank a lot in advance. Madhan!!!! Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted July 20, 2009 Share Posted July 20, 2009 When you export in HTML, JasperReports can not embed the images in the document, so you need to provide a way to get the images produces along the HTML from the server. This is done putting the images in the user session when the report is produced, and providing a mechanism to reference these images in the HTML.The JRHtmlExporterParameter.IMAGES_URI is the customizable url that must be used in the HTML to reference an image. It assumes you have a servlet mapped to the image uri which takes a parameter called image that will be used to find the requested image inside the session.The servelet uses the IMAGES_MAP to find the required image.Giulio Link to comment Share on other sites More sharing options...
spmkkmps Posted July 20, 2009 Author Share Posted July 20, 2009 Giulio,Thanks for your reply. But i dont understand since am using jasper report for the first time. So can you please get me the application structure like where i need to place the image, jrxml and java codings and in the jrxml what needs to be done. Madhan!!!! Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted July 20, 2009 Share Posted July 20, 2009 This is all arbitrary. In general the best choice is to put the jasper files and the required resources in the classpath, but you can even have a reports directory where you put the jasper files, another for the images and so on.The jrxml files are not necessary, they are just the sources for the jasper files and are not involved in the report generation.In the jrxml you need to say where the image is. If the image is in the classpath, you can just indicate the image name. If it is in a specific directory, you have to say where the image is. You can for instance have a parameter like IMAGES_DIR, the image expression would look like:$P{IMAGES_DIR} + "\myImage.png"The value for the parameter IMAGE_DIR should be set by your application (i.e. ServletContext.getContextPath() + "/images" ).Inside the JasperReports distribution there is a sample webapp that should help you.Giulio Link to comment Share on other sites More sharing options...
spmkkmps Posted July 22, 2009 Author Share Posted July 22, 2009 Guilio,It doesn't work for me. Whatever you said i tried but it works only for pdf and excel. For htmlexporter it doesn't work. Can you get me the solution to display image when exporting using htmlexporter. Anyway i need to thank for your suggestions given for my post. Madhan!!!! Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted July 22, 2009 Share Posted July 22, 2009 What iReport version? In the exporter options you can set the dir where put the images when exporting in HTML. What I think is that the images are correctly produces, but are not placed in the same directory as the html file due to some settings you have set.Giulio 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