This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Furthermore, even with the methods provided by the ServletContext object, it is not always possible to find the directory dynamically because web applications are not required to be run from a directory.
You said not to ask so I won't but if you can tell us what it is that you're trying to accomplish maybe someone can suggest an alternate approach.