Hi Craig / anyone else following thread,

I agree that this would work if I manually retrieved the URL as a String
environment entry from JNDI, then passed that to the constructor of
java.net.URL ... but I could do the same reading a context init-param (for
example).

What I need is some way in which I can store a URL object in JNDI so that
when an XML parser is reading through an XML document, it can read the DTD
directly from the URL.  I'd like to be able to validate XML documents
automatically, but unless I write a URL resolver and plug it into a parser
(which is quite complicated, as it's used for resolving everything, not just
the DTD, I'm a bit stuck for controlling validation, unless the default
resolver can read directly from the specified DTD.

Thanks,
Chris

----- Original Message -----
From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Thursday, October 31, 2002 6:34 PM
Subject: Re: Using JNDI URLs for embedded XML DTDs, to avoid hard-coding


>
>
> On Thu, 31 Oct 2002, Chris Brown wrote:
>
> > Date: Thu, 31 Oct 2002 09:28:18 +0100
> > From: Chris Brown <[EMAIL PROTECTED]>
> > Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> > To: tomcat-user <[EMAIL PROTECTED]>
> > Subject: Using JNDI URLs for embedded XML DTDs, to avoid hard-coding
> >
> >
> > Hello all,
> >
> > Any ideas as to how I can make an XML DTD/Schema available via a JNDI
URL
> > within Tomcat?
>
> The simplest way to do this is to use a JNDI "environment entry" that
> defines the URL (as a String) and sticks it in the JNDI naming context for
> you.  The actual value to be used is configured in server.xml (or
> your context config file under 4.1).
>
> Nested in your <Context> element, you'd set up something like this:
>
>   <Context path="..." ...>
>     ...
>     <Environment name="url" type="java.lang.String"
>                 value="http://..."/>
>     ...
>   </Context>
>
> and access it from your application like this:
>
>   InitialContext ic = new InitialContext();
>   String url = (String) ic.lookup("java:comp/env/url");
>
> In this way, you can deploy the same WAR unchanged, in different
> environments, by tweaking things in the server.xml file.
>
> A similar alternative would be to use a context initialization parameter,
> which Tomcat lets you configure in server.xml with a <Parameter> element,
> and retrieve it with:
>
>   ServletContext sc = ... context instance passed to your class ...;
>   String url = sc.getInitParameter("url");
>
> In either case, the configured value will be available in the
> contextInitialized() method of a ServletContextListener, or at any other
> time during the execution of your application.
>
> Craig
>
>
> --
> To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail:
<mailto:tomcat-user-help@;jakarta.apache.org>
>
>
>



--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>

Reply via email to