Specify relative path to file in web-application

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:39]
# 1
getServletConfig().getServletContext().getContextPath() function may be of help.You may also want to check out the methods offerd by http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html :getRealPath() , getResourceAsStream() , getResourcePaths() .
KarthikRa at 2007-7-12 8:15:09 > top of Java-index,Development Tools,Java Tools...