Specifying path to file
Following code works fine:
try {
FileInputStream inp = new FileInputStream("C:\\MPolls\\dbconnection.properties");
props.load(inp);
inp.close();
DriverName = props.getProperty("jdbc.drivers");
DBURL = props.getProperty("jdbc.url");
} catch (FileNotFoundException ex) {
ex.printStackTrace(out);
}
Is it possible to put properties file in web-application's root and specify relative path to it.
If possible, how?
a better idea is to define a VM variable and pass it to your program :
java -Djdbc_config="C://MPolls//dbconnection.properties"
in your code, use this : FileInputStream inp = new ... new FileInputStream(System.getProperty("jdbc_config"));
Have no need to point absolute path to file different way.
The issue is different:
I need to specify relative path to properties file.
I.e. put properties file into web-application root.
But have no idea how to specify path.
the purpose is to make properties file editable by end-user and deploy it with web-application.