Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 61227 invoked by uid 500); 3 Oct 2001 17:10:54 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: tomcat-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 61216 invoked from network); 3 Oct 2001 17:10:54 -0000 Message-ID: <029f01c14c2e$79c11c70$0301a8c0@white> From: "Bob Byron" To: , References: <20011003092700.P49410-100000@localhost> Subject: Re: Open a file? Date: Wed, 3 Oct 2001 12:11:38 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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" To: 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 > > 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 >