**********************************************************************
The path does not have to be relative to any of the server environments.
Any network or file system path will do.
Plus, your code will return null for the path. It will also return null when the passed in path is in an archive or is simply a mapping.
***********************************************************************
I agree any network or filesystem path will be fine. What if we dont know the filesystem itself on the webserver?
But getServletContext().getRealPath("") doesnt return null, it gives the real path to the context. For example if you have installed tomcat in /usr/local/tomacat/webapps/ROOT and the WEB-INF is inside ROOT ie /usr/local/tomacat/webapps/ROOT/WEB-INF. And if you use getServletContext().getRealPath("") on any of the servlet it will return /usr/local/tomacat/webapps/ROOT. I cant understand why you said it returns null.