I need to get the full path to a dir on my UNIX server running Tomcat.
This has to be done inside a bean, not jsp or servlet.
I've tried:
File f = new File("");
String apath = f.getAbsolutePath();
and all I'm getting is the full path up to my tomcat bin plus my relative
path.
I've also tried using getServletContext like following
public class UojTestNo extends HttpServlet {
...
public String getPath()
{
String MyRelativePath="mypath";
ServletContext ctx = getServletContext();
String path = ctx.getRealPath("/" + MyRelativePath);
return path
}
...
}
but I get a java.lang.NullPointerException at the getServletContext()
What I am doing wrong?
Thanks
Massimo