I am trying to create a config file to keep some settings such that my servlet can access it to retrieve some settings (avoid hardcoding values into the servlet).
I want to try to keep it under WEB-INF (so as to disallow public access). But when i do a io FileInputStream in = new FileInputStream("configFile"); i keep getting error saying it cannot find the file.
Did anyone do something similar before? what should be the path that i should supply?
I know i can use web.xml to keep settings. But i want to keep a setting for example names whose values may consist of Tom, Dick and Harry. My servlet would read this setting and store the values in an ArrayList. If i use web.xml i can only store one name. Maybe someone can help me out with other alternative solutions?
If you go with the ResourceBundle as Jeroen has suggested, just make sure your properties file is in a place where you webapp can see it. Either put it in the WEB-INF/classes directory or pack it in a jar under the WEB-INF/lib directory.
Another alternative is to use ServletContext.getResourceAsStream(path).