You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Scott Walter <tx...@yahoo.com> on 2001/04/02 20:18:17 UTC

Storing property file

Hi,

I want to get your guys/girls input on the following:

I am building an app that will run under Tomcat and in
the future J2EE app servers.  Currently I am storing
parameters for connecting to a database (i.e. jdbc
url, driver, etc.) inside a .properties file.  

When the app is started for the first time I want the
user to enter values for db parameters and then to
write them to the property file.

Currently I am reading the properties file off the
classpath via getResource().  Is there anyway that I
can figure where exactly on the file system where the
properties file is located at so I can write to it in
the correct location???

I took a look at the Jive open source project and they
have the user put the location where the file exists
on the file system as an entry in the properties file,
I would like a more elegant solution.

thanks in advance.


=====
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scott

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/?.refer=text

beans

Posted by Sam Terburg <Sa...@Magicminds.com>.
I have a Bean which is storing user-info, like name, password, email, age,
address, etc.

I have another bean which want to access that info / that bean. I don't want
to pass the info along the jsp page, instead i want to directly access that
user-bean in the other bean.

is there something like getBean(beanname) ?

Thanx (if you have the answer, or even reply).
Happy X-Mas!

Sam.



Re: Storing property file

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 2 Apr 2001, Milt Epstein wrote:

> On Mon, 2 Apr 2001, Scott Walter wrote:
> 
> > Hi,
> > 
> > I want to get your guys/girls input on the following:
> > 
> > I am building an app that will run under Tomcat and in
> > the future J2EE app servers.  Currently I am storing
> > parameters for connecting to a database (i.e. jdbc
> > url, driver, etc.) inside a .properties file.  
> > 
> > When the app is started for the first time I want the
> > user to enter values for db parameters and then to
> > write them to the property file.
> > 
> > Currently I am reading the properties file off the
> > classpath via getResource().  Is there anyway that I
> > can figure where exactly on the file system where the
> > properties file is located at so I can write to it in
> > the correct location???
> > 
> > I took a look at the Jive open source project and they
> > have the user put the location where the file exists
> > on the file system as an entry in the properties file,
> > I would like a more elegant solution.
> 
> FWIW, resources found via getResource() can be written to, when
> appropriate.  I have an article written by Jason Hunter (author of
> O'Reilly's Servlets book) from JavaWorld Dec. 1998 that covers the
> changes from servlet spec 2.0 to 2.1 (I don't have the exact URL, but
> you should be able to find it from that info), and it talks about this
> there (page 7, near the bottom, "Writing to an abstract resource").
> Take a look at that for details.
> 

Note that while it is *possible* the URL returned to you by
getResource() will be writeable, this is definitely not guaranteed.  For
example, if your container runs the webapp directly out of a WAR file, it
is highly unlikely that you will be able to do this.

There is no elegant portable solution to writeable resources within the
servlet API.  This was discussed by the expert group during the
development of the 2.3 spec, but unfortunately no consensus was
reached.  Using the absolute pathname of a disk file is probably the
closest thing to a portable solution.

Craig McClanahan



Re: Storing property file

Posted by Milt Epstein <me...@uiuc.edu>.
On Mon, 2 Apr 2001, Scott Walter wrote:

> Hi,
> 
> I want to get your guys/girls input on the following:
> 
> I am building an app that will run under Tomcat and in
> the future J2EE app servers.  Currently I am storing
> parameters for connecting to a database (i.e. jdbc
> url, driver, etc.) inside a .properties file.  
> 
> When the app is started for the first time I want the
> user to enter values for db parameters and then to
> write them to the property file.
> 
> Currently I am reading the properties file off the
> classpath via getResource().  Is there anyway that I
> can figure where exactly on the file system where the
> properties file is located at so I can write to it in
> the correct location???
> 
> I took a look at the Jive open source project and they
> have the user put the location where the file exists
> on the file system as an entry in the properties file,
> I would like a more elegant solution.

FWIW, resources found via getResource() can be written to, when
appropriate.  I have an article written by Jason Hunter (author of
O'Reilly's Servlets book) from JavaWorld Dec. 1998 that covers the
changes from servlet spec 2.0 to 2.1 (I don't have the exact URL, but
you should be able to find it from that info), and it talks about this
there (page 7, near the bottom, "Writing to an abstract resource").
Take a look at that for details.

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
mepstein@uiuc.edu