/bar is your servlet mapping which has nothing to do with a real path on your system. You want to get the real path from the base of the context:
String contextPath = getServletContext.getRealPath("/");
Check is that is null before using it as it *will* be null if you serve your app directly from a .war file rather than from a directory on the file system.
Now do contextPath+foo.html and create a File object from that.
Jake
At 02:35 PM 1/6/2003 +0100, you wrote:
Hi, could anyone tell me how to access files using relative paths from a servlet? Say, if servlet is mapped to /bar and the file foo.html is in the webapps top dir. How do I access the foo.html file from the servlet. I tried ../foo.html, /foo.html and even getServletContext().getRealPath(/bar)+"/../foo.html" but none works.Any pointers? -- Øyvind Hvamstad -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>