i am trying to add an image to a pdf file using itext in a java class (struts action class). when the project gets uploaded to the server the path will be different. therefore i am trying to keep all the paths relative. I thought this would be straightforward but is proving quite difficult.
here are some configurations i have already tried:
logo = Image.getInstance("../imag
(creates relative to c: and not my project path)
logo = Image.getInstance(new URL("http://
" + request.getServerPath() + ":" + request.getServerPort + "/images/nbm_logo_light.jp
(security didn't allow anonymous access to the url)
logo = Image.getInstance(mapping.
) + "/images/nbm_logo_light.jp
(seems to point to root of tomcat directory)
Is there any easy way to dynamically retrieve the project root inside a java class?