Reputation: 5146
i need to access a configuration file with some properties from a class inside a webapp.
The webapp consist of a servlet that uses another class.
In that class i want to access a configuration file.
Which is the best way?
Upvotes: 0
Views: 279
Reputation: 16595
you can put a properties file under your WEB-INF/classes
directory. in that way it wil be visible on the classpath, then in your java class you can use :
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("your_file.properties");
Upvotes: 1
Reputation: 240860
Use Properties
file and read it from ContextListener
and store it in some application wide accessible map it properties are not too many.
Also you can use web-param
Upvotes: 2