Tomcat 4.1.24 configuration settings

Discussion in 'Java' started by Paul Ackerman, Jul 29, 2003.

  1. 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
     
    Paul Ackerman, Jul 29, 2003
    #1
    1. Advertising

  2. Paul Ackerman

    Wendy S Guest

    "Paul Ackerman" <> wrote
    > 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.

    --
    Wendy in Chandler, AZ
     
    Wendy S, Jul 29, 2003
    #2
    1. Advertising

  3. In alt.apache.configuration Paul Ackerman <> wrote:
    > 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
     
    Davide Bianchi, Jul 29, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maellic
    Replies:
    4
    Views:
    443
    Maellic
    Dec 15, 2003
  2. Siegfried Heintze
    Replies:
    0
    Views:
    2,278
    Siegfried Heintze
    Oct 24, 2005
  3. sjoshi
    Replies:
    0
    Views:
    6,625
    sjoshi
    Sep 27, 2005
  4. leeanne
    Replies:
    0
    Views:
    1,871
    leeanne
    Sep 24, 2008
  5. donet programmer
    Replies:
    3
    Views:
    1,548
    Gregory A. Beamer
    Nov 20, 2009
Loading...

Share This Page