You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Manik Surtani <ma...@espadanet.com> on 2000/01/31 07:03:37 UTC

Help with XML on Tomcat!!

Hi,

Just need a bit of help with XML ....

Okay ... my knowledge of XML at this moment is *very* limited - limited
to just theroetical stuff I see on the W3C docs!  Practically using this
stuff is still a bit hazy - perhaps it is the lack of a de-facto parser
for xml?  Or maybe this is inherent in the eXtensibility of XML in the
first place ... !

Here's what I want to do ...

We are writing an app for Tomcat, using servlets and JSPs.  This app is
an online site which is 100% web-administered.  As such, I need to save
site config settings in a file somewhere.

I would like to use an XML format for this config file - similar to
Tomcat's web.xml.

Are there any classes built-in to JSP1.1/Servlets2.2 or the Tomcat
classes to help me read and parse such a file?  Basically, to read the
parameters specified in such a file into Java variables?

E.g., if I need to store a database access string in this config file,

<DATABASE_HOST>my.database.host.com</DATABASE_HOST>
<DATABASE_USER>MyUser</DATABASE_USER>
<DATABASE_PASSWORD>QazWsxEdcRfv</DATABASE_PASSWORD>

Help much appreciated!!

--
Manik Surtani
Chief Technology Officer
Espada (Pvt.) Ltd.
http://www.espadanet.com
ICQ: 853533




Re: Help with XML on Tomcat!!

Posted by "Craig R. McClanahan" <cm...@mytownnet.com>.
Manik Surtani wrote:

> I would like to use an XML format for this config file - similar to
> Tomcat's web.xml.
>
> Are there any classes built-in to JSP1.1/Servlets2.2 or the Tomcat
> classes to help me read and parse such a file?  Basically, to read the
> parameters specified in such a file into Java variables?
>

There's nothing built in to the JSP or Servlets specifications themselves
for XML parsing (or anything else -- they are just specs).

Tomcat happens to use the "Project X" parser from JavaSoft (available under
Developer's Connection, I think) -- there are other sources for parsers as
well, including the "xml.apache.org" project, the AlphaWorks site at IBM,
and a few others.  There's also work going on to create a standard Java API
for interfacing to XML parsers, so you can plug in any parser you want with
no code changes.  Check the JavaSoft web site for details.

> Manik Surtani

Craig McClanahan



Re: Help with XML on Tomcat!!

Posted by Antonio Calzada <an...@it.lth.se>.
----- Original Message -----
From: Manik Surtani <ma...@espadanet.com>
To: jakarta <ge...@jakarta.apache.org>
Sent: Monday, January 31, 2000 7:03 AM
Subject: Help with XML on Tomcat!!


> I would like to use an XML format for this config file - similar to
> Tomcat's web.xml.
>
> Are there any classes built-in to JSP1.1/Servlets2.2 or the Tomcat
> classes to help me read and parse such a file?  Basically, to read the
> parameters specified in such a file into Java variables?

Take a look at the source files in org.apache.tomcat.util.* - like
XMLHelper.java - and org.apache.tomcat.startup.Tomcat.java where it's used.
There you can find classes used by tomcat to build it's classtructure out of
server.xml at startup. Using that you could write stuff like:

<DBConnectionManager>
    <ConnectionsToDSN Server="MSSQL.mynet.com" User="foo" Password="123"
MaxConnections="10" Timeout="30"/>
    <ConnectionsToDSN Server="Oracle.mynet.com" User="foo" Password="123"
MaxConnections="10" Timeout="30"/>
</DBConnectionManager>

The same principle is used for jakarta-ant. It seems to be quiet flexible.
For example the class for DBConnectionManager can easily be replaced, by
changing the DBConnectionManager tag to something like:

<DBConnectionManager className="com.mynet.OtherDBConnectionManager">

/Antonio