tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralph Einfeldt" <ralph.einfe...@uptime-isc.de>
Subject AW: AW: Reading properties file from ClassPath (ServletContextListener)
Date Thu, 01 Aug 2002 15:02:35 GMT

To read a property from /WEB-INF/classes/com/foo/My.properties
you shouldn't use getSystemResource*() as it uses the
Systemclassloader which doesn't know anything about the tomcat 
directories. So you have use getResource*() which uses the 
classloader that loaded you current class.

To the use of getResource() against getResourceAsStream():
AFAIK the only benefit is that you save one line of code.

Ralph Einfeldt
Uptime Internet Solution Center GmbH
Hamburg, Germany
Hosting, Content Management, Java Consulting
http://www.uptime-isc.de 

> -----Urspr√ľngliche Nachricht-----
> Von: petra staub [mailto:calc42@hotmail.com]
> Gesendet: Donnerstag, 1. August 2002 16:45
> An: tomcat-user@jakarta.apache.org
> Betreff: Re: AW: Reading properties file from ClassPath
> (ServletContextListener)
> 
> with classpath i mean somewhere in the package of my
> web application (context). this would match the first
> path you pointed out in your answer 
> (webapps/{Context}/WEB-INF/classes/com/foo/My.properties).
> 
> actually i have no special reason i choose getSystemResource
> instead of getSystemResourceAsStream. what whould be the
> benefit of doing do (maybe buffering related aspects?)?

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message