I avoid to use request.getRealPath("/"); because this method was deprecated ,so I used the new version servletContext.getRealPath("");
but it retrns null.
String serverPath = servletContext.getRealPath("");
System.out.println("serverPath = "+serverPath);
================================
output:
serverPath = null