I ran into a problem with accessing files within WebContent folder (in this case I need to access WEB-INF folder)
This is where I try to access WEB-INF folder.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String dbPath = "/WEB-INF/musicDb.db";
String xmlPath = "/WEB-INF/musicDb.xml";
ServletContext context = null;
context = getServletContext();
String test = context.getRealPath(xmlPath);
File f = new File(test);
if (f.exists()) {
}
}
I have musicDb.xml ready in WEB-INF folder, however, by debugging, I always get this path instead
{my local project path}/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/9321A1/WEB-INF/musicDb.xml
I suspect it has something to do with WebContent folder not being included in build process. This might be wrong.
Pretty much every tutorial/suggestion/article I've found so far point me to this approach using
getServletContext().getRealPath()
which doesn't seem to work in my case
Any help would be appreciated.
Thang