.getServletContext().getRealPath("/") gives you just a way to get the absolute path of your context. i.e. the root of your application. But after this you will have to append to it the relative location of your file to get the complete path. For say you are using
Tomcat - you have your application myApp deployed on Tomcat. You have tomat installation directory as C:\Tomcat. You will see a directory with name myApp inside tomcat/webapps directory. .getServletContext().getRealPath("/") - will give you C:\Tomcat\webapps\myApp. Relative path will be where inside this directory you have placed your file. And we will have to add this to the context path to get the absolute path.