commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: Deigester.parse(File f) method
Date Sat, 13 Nov 2004 16:58:49 GMT
Without seeing the exception message and the stack trace, it is almost
impossible for anyone to offer you much assistance.

If you're using the parse(File) method, one thing to ensure is that
you are calculating the path of the file you are trying to parse
correctly.  If it is a resource inside your webapp, you will need to
calculate that path based on the document root of your webapp:

  ServletContext context = ...;
  String path = context.getRealPath() + "/WEB-INF/web.xml";
  File file = new File(path);
  digester.parse(file);

However, this only works when getRealPath() actually returns something
-- it is not required to do so if the container is not running the app
straight out of a directory.  A better way to reference resource files
inside the webapp is like this:

  ServletContext context = ...;
  InputStream stream = context.getResourceAsStream("/WEB-INF/web.xml");
  digester.parse(stream);

Craig



On Sat, 13 Nov 2004 21:17:18 +0600, Md. Rezaul Hoque
<java.mail.archive@gmail.com> wrote:
> Hello,
> 
> I m facing problem with Digester.parse() method. Within console
> application...it's working fine...but i am using it within tomcat it's
> throwing SAXException...........
> 
> Can anybody can give any suggestion.....
> 
> I am waiting for reply....
> 
> Thanks in advance...
> 
> Babu
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message