[jdom-interest] reading web.xml
Alex Colic
alex.colic at pop-ware.com
Wed Aug 15 09:34:05 PDT 2001
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Alex Colic.vcf
Type: application/vcard
Size: 395 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010815/a562d290/AlexColic.bin
More information about the jdom-interest
mailing list