Move your property files under WEB-INF/classes . Then download it as follows:
prop.load(getClass().getResourceAsStream("sample.properties"));
You can also put it in a subdirectory in classes . In this case, change the call to getResourceAsStream() .
To be more secure on a multi-user system, you can use Thread.getContextClassLoader().getResourceAsStream() instead.
For the properties file to arrive in the classes folder of your war file, you must put it in the resources folder in your project (if you use maven) or only in the src folder if you do not use a structure structure like maven.
Alexr
source share