Getting relative reference to file in WAR
843841Nov 24 2004 — edited May 30 2006Hi
Please could you advise me on how I can get a relative reference to a file in my web application.
Part of my structure is:
I have a class:
<app>/WEB-INF/classes/package/MyClass.class
Which needs to create a file object from:
<app>/WEB-INF/xml/black.xml
As the app could be deployed anywhere and on any OS i need to reference the file relatively in the MyClass class.
Please could someone tell me how to do this. I have tried:
MyClass.class.getResource("xml/black.xml");
getClass().getResource("xml/black.xml");
getClass().getClassLoader().getResource("xml/black.xml")
All return null.
Thanks