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" <[EMAIL PROTECTED]> >Reply-To: "Tomcat Users List" <[EMAIL PROTECTED]> >To: "Tomcat Users List" <[EMAIL PROTECTED]> >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:[EMAIL PROTECTED]] > > Gesendet: Donnerstag, 1. August 2002 16:05 > > An: [EMAIL PROTECTED] > > 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:[EMAIL PROTECTED]> >For additional commands, e-mail: ><mailto:[EMAIL PROTECTED]> > _________________________________________________________________ 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:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>