Tomcat 4.1.24 configuration settings

P

Paul Ackerman

I am trying to write a Java-based web application. I am
using Tomcat 4.1.24 as my servlet/JSP engine. The
application uses MySQL.

My question is this: I want to use two databases, one for
production, one for testing. I have two directories under
the webapps directory, prod and test. I want the
application to know which directory it is in and point to
its respective database. Is there a way to do this using
the directory name? Or should I read it out of a file, like
web.xml?

I have tried to parse my own XML file, but the application
will only read out of the $CATALINA_HOME\bin directory. I
can't seem to get it to read a file from the home directory
of the application.

I haven't tried using JNDI or DataSources yet because it
looks like they use the server.xml file. If I used that I
think I would still have a problem of not being able to
decide which entry to use.

I currently have only one version of Tomcat running. Do I
need to run another Tomcat instance to make this work? If
so, how does the application know which version of Tomcat to
use?

Thank you in advance for your assistance.

- Paul Ackerman
(e-mail address removed)
 
W

Wendy S

Paul Ackerman said:
I am trying to write a Java-based web application. I am
using Tomcat 4.1.24 as my servlet/JSP engine. The
application uses MySQL.
My question is this: I want to use two databases, one for
production, one for testing. I have two directories under
the webapps directory, prod and test.

Why not have one webapp that looks exactly like it will in production,
except for a single setting that tells it which database to use? I use a
..properties file for that, but then I don't use JDBC.

This way, you do all of your testing, make one change and deploy the webapp.
I usually have two versions of my webapp deployed under Tomcat, under two
different context (webapp) names: bentest and benweb. The 'test' one is
pointed at the test database, and the other is in production and pointed at
live. The only difference between the two versions is the
unidata.properties file that holds the path to the database account.
 
D

Davide Bianchi

In alt.apache.configuration Paul Ackerman said:
its respective database. Is there a way to do this using
the directory name? Or should I read it out of a file, like
web.xml?

You'd better put the database connection url in some kind of
configuration file and then refer to that in the code. This way
no matter the name of the directory and you can easily change the
database later.

See the documentation for the Servlet package and the Properties
class.

Davide
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top