[jdom-interest] reading web.xml
james todd
james.todd at Sun.COM
Wed Aug 15 10:01:25 PDT 2001
i wonder if "/web.xml" vs "/WEB-INF/web.xml" will work given everything
*under* WEB-INF is web application root.
hth,
- james
Alex Colic wrote:
>
> Hi,
>
> I hope someone call help with reading the web.xml file of a web app. I want
> to create a nice web page for the user to edit these values.
>
> I am getting an error parsing the file. In the parse method creating the
> document failed.
> My code is as follows:
>
> In my servlet:
>
> String webConfig="/WEB-INF/web.xml";
> ServletContext context = servlet.getServletContext();
> InputStream input = context.getResourceAsStream(webConfig);
> if (input == null)
> throw new UnavailableException("web.xml file cannot be found");
> try
> {
> pwXMLUtility util=new pwXMLUtility(input);//my rapper class
> }
> catch(Exception e){}
>
> In my wrapper class:
> public pwXMLUtility(InputStream in) throws rdXMLException, IOException
> {
> DataInputStream reader=new DataInputStream(in);
> StringBuffer buf=new StringBuffer();
> String strCurrentLine;
> while(true)
> {
> strCurrentLine=reader.readLine();
> if(strCurrentLine==null) break;
> buf.append(strCurrentLine);
> }
> strDocument=buf.toString();
> parseDoc();
>
> }
>
> public void parseDoc () throws rdXMLException {
>
> SAXBuilder builder=new SAXBuilder(false);
>
> try
> {
> Document doc=builder.build(new
> StringReader(getRawDocument()));
> setXMLDocument(doc);
> }
> catch(Exception e)
> {
> System.out.println("pwXMLUtility: exception " + e.getMessage());
> throw new rdXMLException(" Could not build xml document");
> }
> } //parseDoc
>
> }
>
> Being new to XML any help, guidance, code corrections etc. is highly
> appreciated.
>
> Regards
>
> Alex
>
> ------------------------------------------------------------------------
> Name: Alex Colic.vcf
> Alex Colic.vcf Type: application/vcard
> Encoding: quoted-printable
More information about the jdom-interest
mailing list