tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Werner van Mook <>
Subject Re: reading file in ServletContextListener
Date Sun, 27 Nov 2005 22:32:14 GMT
To make it more clear of what I try to do here is the complete method  
in which I try to read a file.

     private void list() throws Exception {
         XMLReader parser = XMLReaderFactory.createXMLReader(
         parser.setContentHandler(new PeopleHandler());

This parse method want an InputSource. Sorry Wendy it didn't work.
I tried filling in a fully qualified URI. It completely stops tomcat  
from starting.
The URI is to a file in the webapp which is trying to start.

And see there we have a chicken and egg problem.
The web app needs the file to start.
The file is not there if there is no web app.

On Nov 27, 2005, at 11:06 PM, Wendy Smoak wrote:

> On 11/27/05, Werner van Mook <> wrote:
>> In my class which implements ServletContextListener I try to read a
>> file.
>>   it looks like :
>>     parser.parse("friends.xml");
>> When I start tomcat 5.5.12 I get a FileNotFound Exception on the
>> friends.xml file.
>> The file is in the root of my web-app.
>> I also tried "/friends.xml" but alas it did not work.
> Try using ServletContext's getResourceAsStream() method to find the
> file, assuming that you have a 'parse' method that will take an
> InputStream.
> --
> Wendy
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message