I have a servlet that uses another class for reading .XML file, here is the servlet simple doGet() :
private checkDBStatus;
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
checkDBStatus = new checkDBStatus();
String returnText = checkDBStatus.getText();
// Set response content type
response.setContentType("text/html");
// Actual logic goes here.
PrintWriter out = response.getWriter();
out.println(returnText);
}
The file path in checkDBStatus is XMLS/DB.xml, when running on a Java class like Program(main) checkDBStatus works fine with the right path, but when a Get request is handled in servlet class I get FileNotFoundException with file path \IBM\SDP\XMLS\DB.xml (this directory was not found in my file system as well, I have IBM RAD).
Anyone had encounter this problem?
Here is the code that reads thr .xml:
File fXmlFile = new File("XMLS/DB.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile); // the rest is just parsing...