[jdom-interest] DTD locations when reading XML from a resourc e jar

philip.nelson at omniresources.com philip.nelson at omniresources.com
Sat May 5 13:37:22 PDT 2001


> Hello all, ran into a problem just now and I'm wondering if anyone has
> ny helpful hints.
> 
> I have a servlet packaged into a jar (war) file, and the jar also
> includes some XML configuration files which the servlet reads on
> startup. To read the XML I use code essentially like the following:
> 
> InputStream in = getServletContext().getResourceAsStream(xmlfile);
> SAXBuilder parser = new SAXBuilder(validate);
> Document doc = parser.build(in);

You should be able to build a custom EntityResolver and use it with
SAXBuilder.  Sax will call that instead of trying to locate the file itself.

Use builder.setEntityResolver()



More information about the jdom-interest mailing list