You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ALEXANDROS KOTSIRAS <AL...@prodigy.net> on 2002/05/28 00:51:28 UTC

Re: using beans to load properties file

Why don't you use ResourceBundle ?
You just place your foo.properties file in any directory that is included in
your classpath.
I have it in WEB-INF/classes.
Then Java will find it without specifying it's exact location.

Alex

----- Original Message -----
From: Jason Novotny <no...@nlanr.net>
To: <to...@jakarta.apache.org>
Cc: <rb...@actv.com>
Sent: Friday, May 26, 2000 5:41 PM
Subject: Re: using beans to load properties file


>
>     Thanks Rick,
>
>     I have my web application packaged pretty nicely using the ANT
build.xml
> stuff, and I want to allow developers to simply deploy my package for
their
> particular site, changing only the values in "foo.properties". It seems
like a
> pain in the %$# to have to ask them to modify tomcat.sh (or tomcat.bat on
> Windows) accordingly :-( In some sense, it's easier to just say "modify
line 32
> of Config.java to reflect the location of foo.properties" and issue
"build".
>     I recall seeing this sort of discussion earlier in the mailing list,
and
> I'm surprised at how painful this task is.
>
>     Jason
>
>
> Rick Bosch wrote:
>
> > pass the path in the startup script in the startup script ( ie java
> > -Dpropdir=here/are/my/properties org.start.Tomcat ).  in a j2ee
compliant
> > you can pass stuff in server.xml and then get it using jndi , but not
> > tomcat.
> >
> > rick
> >
> > ----------
> > >From: Jason Novotny <no...@nlanr.net>
> > >To: tomcat-user@jakarta.apache.org
> > >Subject: using beans to load properties file
> > >Date: Fri, May 26, 2000, 5:13 PM
> > >
> >
> > >
> > >     I'm trying to stay away from servlets and just use beans and very
> > > simple JSP's. I have a bunch of beans that all do different things and
> > > make use of a "foo.properties" file for some user configurable
settings.
> > > I have a ConfigBean that simply loads the properties file and has
> > > methods to let the other beans know what the values specified in
> > > "foo.properties" are. However, the ConfigBean has to know exactly
where
> > > the "foo.properties" file is located. I would like some way to specify
> > > this (probably in a web.xml or something) and have that accessible to
> > > the ConfigBean.... and I really don't want to have to write any JSP
like
> > > "getServletContext.getInitParameter("foo.properties")"- I'd like that
in
> > > the Bean somehow.
> > >     Any ideas?
> > >
> > >     Thanks, Jason
> > >
> > >
> > > --
> > > Jason Novotny              novotny@nlanr.net
> > > Home: (510) 839-6026       Work: (650) 604-4628
> > > NLANR Applications Support http://dast.nlanr.net
> > >
> > >
> > >
> > >
> >
> --------------------------------------------------------------------------
> > > To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> > > For additional commmands, email: tomcat-user-help@jakarta.apache.org
> >
>
> --------------------------------------------------------------------------
> > To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commmands, email: tomcat-user-help@jakarta.apache.org
>
> --
> Jason Novotny              novotny@nlanr.net
> Home: (510) 839-6026       Work: (650) 604-4628
> NLANR Applications Support http://dast.nlanr.net
>
>
>
>
> --------------------------------------------------------------------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org
>