Assuming you have your properties file inside your war, in a package in the source folder, this is how you load it in the managed bean:
Properties properties = new Properties();
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
properties.load(classLoader.getResourceAsStream("/yourfile.properties"));
} catch (IOException e) {
// handle exception
}
// then initialize attributes with the contents of properties file. Example:
property1 = properties.getProperty("property1");
property2 = properties.getProperty("property2");
Then, when user updates values (submit forms) and you want to update the properties file, do the following:
properties.setProperty("property1", property1);
properties.setProperty("property2", property2);
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL url = classLoader.getResource("/yourfile.properties");
properties.store(new FileOutputStream(new File(url.toURI())), null);
} catch (Exception e) {
// handle exception
}
If the properties file is not in the war (it's in the file system of the server) it is also possible but a little more complex..
EDIT: as BalusC explained, having the properties file that changes inside your war is not convenient because if you redeploy your war, then changes are lost. You could put the properties file in the file system of the server if you have access to it; or don't use properties files (use database instead)