relative image path

By: Brett - bsutton
relative image path
2003-03-03 14:37
I am creating reports which will be deployed to multiple web sites (each with a different URL) and on multiple machines (each with a different directory structure).
My reports include images and because of the different deployment environments I need to make the image paths relative to where the reports are stored or at least to the WEB-INF (I'm working with servlets).

Is their any way to specify a relative path for an image. I've tried the obvious file://./image.jpg and file://image.jpg neither of which is working.

Ideally I need to be able to tell the JRHtmlExporter class the root directory in which it should go looking for the images.

P.S. I known the ImageExpression tag looks in the classpath but I'm unable to use that for other environmental reasons (i.e. I have no control over the classpath).

By: Peter Kohlendorfer - kohlendorfer
RE: relative image path
2003-03-04 00:38

first you do not need the "file://" prefix. Second you need to take care about the Java string escape character "/". An example for a working relative path would be: "..//images//image.gif"



By: Teodor Danciu - teodord
RE: relative image path
2003-05-10 03:30


If you take a look at the supplied "webapp" sample
you can see that it displays an image.
This image is located by passing the base
directory as a parameter to the report when filling.

I hope this helps.

By: Adrian Dimulescu - dadi
RE: relative image path
2003-11-20 05:51

I'm coming back to this subject: I have seen the way the webapp example deals with the path to the image -- but that involves sending a parameter to the report which I would prefer avoiding.

Isn't there a simpler solution using a relative path ?

Thank you,

By: Teodor Danciu - teodord
RE: relative image path
2003-11-20 23:37


Images or subreports can also be loaded from classpath.
You make the expression of type String and use the
classpath relative location of the image file.

Maybe this suits your needs.

Thank you,
2002 JI Open Discussion's picture
Joined: Aug 10 2006 - 3:28am
Last seen: 16 years 7 months ago

0 Answers:

No answers yet