tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "petra staub" <cal...@hotmail.com>
Subject Re: AW: Reading properties file from ClassPath (ServletContextListener)
Date Thu, 01 Aug 2002 14:45:07 GMT

hi ralph,

thanks for your quick reply.

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?)?



>From: "Ralph Einfeldt" <ralph.einfeldt@uptime-isc.de>
>Reply-To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
>To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
>Subject: AW: Reading properties file from ClassPath 
>(ServletContextListener)
>Date: Thu, 1 Aug 2002 16:27:02 +0200
>
>What do you mean with 'classpath'?
>
>Tomcat ignores the classpath environment variable.
>So your property file has to reside in a directory
>that is known to tomcat.
>Even using the SystemClassLoader (which is done when
>you use getSystemResource()) won't help because the
>classpath is cleared in the startsrcipt of tomcat.
>
>So the file has to one of these:
>     * webapps/{Context}/WEB-INF/classes/com/foo/My.properties
>     * $CATALINA_BASE/common/classes/com/foo/My.properties
>     * $CATALINA_BASE/classes/com/foo/My.properties
>
>To read more about this:
>http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html
>
>BTW: Is there any reason why you use getSystemResource()
>instead of getSystemResourceAsStream() ?
>
>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:05
> > An: tomcat-user@jakarta.apache.org
> > Betreff: Reading properties file from ClassPath
> > (ServletContextListener)
> >
> > I have a registered class as a ServletContextListener.
> > At application start I want to read a Properties file
> > from the classpath, doing the following:
> >
> > myProps = new Properties();
> > try {
> >    URL url = ClassLoader.getSystemResource("com/foo/My.properties");
> >    InputStream istream = url.openStream();
> >    myProps.load(istream);
> > } catch (Exception exp) {
> >
> > }
> >
> >
>
>--
>To unsubscribe, e-mail:   
><mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: 
><mailto:tomcat-user-help@jakarta.apache.org>
>




_________________________________________________________________
Mit MSN Fotos können Sie kinderleicht Ihre Fotos ausdrucken und Freunden zur 
Verfügung stellen: http://photos.msn.de


--
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