tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bob Byron" <bby...@radit.com>
Subject Re: Open a file?
Date Wed, 03 Oct 2001 19:58:35 GMT
Does the resource need to be defined in the web.xml file?
If so, how?

Thank You,
Bob

----- Original Message ----- 
From: "Bob Byron" <bbyron@radit.com>
To: <tomcat-user@jakarta.apache.org>; <craigmcc@apache.org>
Sent: Wednesday, October 03, 2001 12:11 PM
Subject: Re: Open a file?


> Thank you Craig!  
> 
> Of course I just sent out a renewed plea for help.  Murphy's
> Law.  I checked for email, sent out my new plea, and 
> then received your email.
> 
> I will be utilizing this technique.  Thanks for the info.
> 
> Bob Byron
> 
> ----- Original Message ----- 
> From: "Craig R. McClanahan" <craigmcc@apache.org>
> To: <tomcat-user@jakarta.apache.org>
> Sent: Wednesday, October 03, 2001 11:28 AM
> Subject: Re: Open a file?
> 
> 
> > 
> > 
> > On Tue, 2 Oct 2001, Bob Byron wrote:
> > 
> > > Date: Tue, 2 Oct 2001 22:03:37 -0500
> > > From: Bob Byron <bbyron@radit.com>
> > > Reply-To: tomcat-user@jakarta.apache.org
> > > To: tomcat-user@jakarta.apache.org
> > > Subject: Open a file?
> > >
> > > Okay, now I need to open the XML file and I am trying to
> > > figure out how to do that.  When I try to open the file "file.xml",
> > > Tomcat 4 is trying to open it relative to "Tomcat\4.0\bin", the
> > > location of the startup scripts.  I want to know what is the
> > > Tomcat centric way of opening a file relative to the webapp
> > > that it is running under?  I hope I have phrased the question
> > > sufficiently for you to understand what I need to do.  I need
> > > a different reference point, one that uses the webapp itself
> > > as a base.
> > >
> > 
> > If you have a file "file.xml" in the top-level directory of your web app,
> > open it like this:
> > 
> >   InputStream stream =
> > getServletContext().getResourceAsStream("/file.xml");
> > 
> > This will work on all servlet containers (not just Tomcat).  It will also
> > work when your web app is run directly from a WAR file rather than being
> > unpacked.
> > 
> > > Thank You,
> > > Bob Byron
> > >
> > >
> > 
> > Craig McClanahan
> >


Mime
View raw message