Reputation: 742
I have a bean class where I'm using a file that I've placed in application/WebContent/common
folder. I have been refering to this file as below
File xsltfile = new File("../common/xhtml2fo.xsl");
in my eclipse, with my working directory configured to
${workspace_loc:enovia/WebContent/WEB-INF}
it worked fine. However, while testing it on a domain-box, I'm getting a file not found exception because its looking for the file in {tomcat-path}/bin/../common/xhtml2fo.xsl.
I don't have access to bean classes in the domain box. So my only option for now is to change my tomcat working directory to WEB-INF.
Upvotes: 2
Views: 845
Reputation: 16060
You can read files in WEB-INF
using this approach:
InputStream in = Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream( "xhtml2fo.xsl" );
or even simpler if you're in a servlet:
getServletContext().getResourceAsStream( "/WEB-INF/xhtml2fo.xsl" )
Cheers,
Upvotes: 1