How to set Relative Path for an Image with Ireport

0
I don't find the way to set a relative path for an image that I've put in my report
my image stay on my WEBAPP-root/img/myimage.gif
ho can I define this in Ireport?
can you help me in a simple step-by-step
thx a lot guys
martina
6sic6's picture
7
Joined: Nov 26 2006 - 8:01pm
Last seen: 12 years 11 months ago

3 Answers:

1
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")
wjones14's picture
Joined: Jul 19 2006 - 11:59pm
Last seen: 3 years 3 months ago
0
thx
I solved with something like a $P{IMAGE} in my report and in my servlet
parameters.put("IMAGE", this.getServlet().getServletContext().getRealPath("img/logo.gif"));
6sic6's picture
7
Joined: Nov 26 2006 - 8:01pm
Last seen: 12 years 11 months ago
0

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 Hiremath

satishmhiremath@gmail.com

satishmhiremath's picture
Joined: Sep 29 2016 - 7:06am
Last seen: 2 years 1 month ago
Feedback
randomness