Kerby82
Kerby82

Reputation: 5146

configuration properties in webapplication java

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

Answers (2)

epoch
epoch

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

Jigar Joshi
Jigar Joshi

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

Related Questions