How to fetch values from catalina.properties to jsp

958 Views Asked by At

I want to put all the values in the catalina.properties and want to use them in jsp instead of having another property file.
Can anyone tell me how to do that.

Right now I'm using system.getProperty("variable name","default value") but it is not working .

1

There are 1 best solutions below

0
On

You might want to try this from a servlet:

InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("/catalina.properties");
Properties properties = new Properties();
properties.load(input);

The rest is just a question of classpath, if everything is correct your properties should be loaded in the properties object where you will be able to retrieve the data you are looking for. Then it's just a question of how you decide to pass it to your jsp.