tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bahbahbo...@go.com
Subject Re: properties file confusion
Date Thu, 10 Apr 2003 17:05:56 GMT
You'll need the leading "/" if you want to locate the file itself without 
the package structure.
 From the docs:

This method delegates the call to its class loader, after making these 
changes to the resource name: if the resource name starts with "/", it is 
unchanged; otherwise, the package name is prepended to the resource name 
after converting "." to "/".

Hope this helps.


At 10:45 AM 4/10/2003 +0200, Marcel Stör wrote:
>Steven Shand wrote:
> >>> local system account as the user, and the system32 directory is the
> >>> default directory for the service.
> >>
> >> Oh yeah, that makes sense. Thanks.
> >>
> >>> You'd be better off putting the location of your properties file in
> >>> your web.xml:
> >>>     <init-param>
> >>>       <param-name>properties</param-name>
> >>>       <param-value>C:/myData/my.properties</param-value>
> >>>     </init-param>
> >>> and reading it from there using
> >>> servletConfig.getInitParameter("properties").
> >>
> >> My class is not a servlet. What would I do it if it is used by a
> >> regular desktop app? So, servletConfig is not an option.
> >
> > you could also just make sure that the properties file lives somewhere
> > on the classpath and use:
> >
> > Properties properties = new Properties();
> > InputStream inputStream = getClass().getResourceAsStream( "/" +
> > "my.properties" );
> > properties.load( inputStream );
>
>Oh, I've tried this before - but without the leading "/". Works just fine if
>I place the properties file in WEB-INF\classes.
>
>Marcel


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


Mime
View raw message