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?

[485 byte] By [BrotherFlamea] at [2007-11-27 3:12:38]
# 1

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"));

java_2006a at 2007-7-12 8:15:08 > top of Java-index,Java Essentials,Java Programming...
# 2

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.

BrotherFlamea at 2007-7-12 8:15:08 > top of Java-index,Java Essentials,Java Programming...
# 3
I assume this is a Servlet?getServletContext().getResourceAsStream("pathFromContextRoot");
masijade.a at 2007-7-12 8:15:08 > top of Java-index,Java Essentials,Java Programming...
# 4
Absolutely so.This works, thank u.
BrotherFlamea at 2007-7-12 8:15:08 > top of Java-index,Java Essentials,Java Programming...