A common problem with reading files from the classpath is the correct placement in your WAR file.
In Java, a servlet called MyServlet can reference a file like this
InputStream is=MyServlet.getClass().getResourceAsStream("/path/to/file/example.txt")
which will find the file stored in
WEB-INF/classes/path/to/file/example.txt
/ .
(, JNDI). :
InputStream fis = FileInputStream(new File("/usr/share/myapp/another-example.txt"));
, DOM , MyServlet :
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = dbf.newDocumentBuilder();
InputStream is = MyServlet.getClass().getResourceAsStream("/path/to/my/example.xml");
Document document = documentBuilder.parse(new InputSource(is));
// And start exploring the NodeList...
NodeList nodeList = document.getFirstChild().getChildNodes();
.