6sic6 Posted January 8, 2007 Share Posted January 8, 2007 I don't find the way to set a relative path for an image that I've put in my reportmy image stay on my WEBAPP-root/img/myimage.gifho can I define this in Ireport?can you help me in a simple step-by-stepthx a lot guysmartina Link to comment Share on other sites More sharing options...
wjones14 Posted January 9, 2007 Share Posted January 9, 2007 I know how to do it with JSF... I put a method in the JSF managed bean named getBaseDir(). It looks like this: public String getBaseDir() { String baseDir = "/WEB-INF/reports"; try { return FacesContext.getCurrentInstance() .getExternalContext() .getResource(baseDir) .getPath(); } catch (MalformedURLException mue) { log.error(mue, mue); return null; } } Then, add a parameter to the parameter map: map.put("base_dir", getBaseDir()); Finally, in the report itself, the graphics element "image expression" is: new File($P{base_dir},"images/logo.gif") Link to comment Share on other sites More sharing options...
6sic6 Posted January 9, 2007 Author Share Posted January 9, 2007 thxI solved with something like a $P{IMAGE} in my report and in my servletparameters.put("IMAGE", this.getServlet().getServletContext().getRealPath("img/logo.gif")); Link to comment Share on other sites More sharing options...
satishmhiremath Posted September 19, 2017 Share Posted September 19, 2017 Use the below expression in the image Expression of jasper report IDE on image properties of the jrxml and the relative image path getClass().getResource("META-INF/resources/webjars/EquityBankTools/themes/default/images/Logo.png").openStream() Satish M Hiremathsatishmhiremath@gmail.com 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