On 04.12.2010 23:07, Pid wrote:
> On 12/4/10 5:41 PM, Mark Eggers wrote:
>> Read about using properties files. They're typically called<name>.properties.
>>
>> Snippet of code that can be placed in a ServletContextListener.
>>
>> String resource = "some.properties";
>> InputStream in = this.getClass().getClassLoader().getResourceAsStream(resource);
>> try {
>> props.load(in);
>> in.close();
>> } catch (IOException ex) {
>> ex.printStackTrace(); // ugly
>> }
>>
>> Note that this is not a complete ServletContextListener. Normally I create a
>> separate class, have that class's constructor read the properties file, and then
>> use the ServletContextListener to create a servlet context attribute with the
>> information.
>
> You can use: ServletContext.getResourceAsStream()
>
> Note: once loaded you'll have to organise reloading yourself - the
> properties don't update just because you change the file on disk.
That's why he was pointed at commons-configuration. It already
implements the ability to change configuration during runtime.
Regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
|