1. Getting the "name"
He called the path of context. If the code works in the context of a web application request, you can get it by calling HttpServletRequest#getContextPath() .
2. Access to a physical / real resource
If you are trying to access the contents of a file / resource in your web application, your best bet is to use one of:
You can also get the physical path on the disk of the file / resource, given the path relative to the web application using ServletContext#getRealPath(String) , but it is not reliable (it does not always work if, for example, you deploy webapp as a WAR).
3. Access to class path resources
In your comment, you tried to access the resource in the directory / WEB -INF / classes. Since WEB-INF / classes / * are web application classes, you can simply access it as if you were accessing any resource of the class path in a Java SE application. Again, if your code is running in a webapp context, you can simply use the following:
In your case, you probably want to use the latter, and then load the properties file by loading properties # (InputStream).
Something along the lines of:
Properties props = new Properties(); props.load(getClass().getResourceAsStream("/reportCustom.properties"));
Jack leow
source share