XML files are not found by Java servlets.
The same code works fine as a standalone Java program.
There is the concept of present working directory. If Tomcat has been started from
$CATALINA_HOME/bin directory, the XML files need to be in that directory. But if Tomcat has
been started as a service, the XML files should be under /
. To avoid the problem, it is
best to give complete pathname to XML file references in servlet code.