Thanks a lot for replying me.
I did try getServletContext().getResourceAsStream("AAA"));
but when I compiled the servlet, it gave me an error saying "non-static method getServletContext() can't be reference from a static context."
The problem is I have to make getDriver() static in order to be called by init() from another servlet.
------------------------------------
public void init(ServletConfig config) {
super.init(config);
String driver = DriverUtilities.getDriver();
}
------------------------------------
public class DriverUtilities extends HttpServlet {
private static Properties pr=new Properties();
public static String getDriver() {
try {
pr.load(getServletContext().getResourceAsStream("AAA"));
} catch(Exception e) {
System.err.println("Error read AAA: " + e);
}
return(pr.getProperty("driver"));
}
}
------------------------------
Another thing is that I have tried to use ResourceBundle like following codes:
private static ResourceBundle bundle=null;
bundle=ResourceBundle.getBundle("AAA");
System.out.println(bundle.getString("driver"));
and set classpath to where AAA is.
It is working but I am wondering if it is a right way to do it.
-------------------------------------
By the way, is there any way to specify where I want to write data into a property file??
Thanks a lot,
Grace