Do the same thing in your servlet too? What's the problem?
application is a pre-defined reference to the servlet context.
Use this:
ServletContext application = getServletContext();
application.getRealPath("/"); //will return the path to the folder as $CATALINA_HOME/webapps/myAppFolder ( if using Tomcat )