Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 22725 invoked by uid 500); 29 May 2001 20:51:04 -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 21375 invoked from network); 29 May 2001 20:49:48 -0000 Received: from unknown (HELO cybershop.ca) (207.236.177.2) by h31.sny.collab.net with SMTP; 29 May 2001 20:49:48 -0000 Received: from cybershop.ca [207.236.177.12] by cybershop.ca [207.236.177.2] with SMTP (MDaemon.v2.8.5.0.R) for ; Tue, 29 May 2001 16:38:44 -0400 Message-ID: <3B140A9A.14FD10AD@cybershop.ca> Date: Tue, 29 May 2001 16:46:19 -0400 From: Bo Xu X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: tomcat-user@jakarta.apache.org Subject: Re: Servlets and relative paths References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-MDaemon-Deliver-To: tomcat-user@jakarta.apache.org X-Return-Path: bo@cybershop.ca X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Chris McNeilly wrote: > I've got a servlet and am trying to open files. The problem is that its > defaulting to the tomcat/bin directory whenever I attempt to refer to > them. How can I change this? Hardcoding the path isn't such a good > idea as my dev environment is different from production. These are xml > and xsl files and they are located on the webroot. > > Thanks, > > Chris Hi :-) from several emails in Servlet-List and this List: * InputStream is = this.getServletContext(). getResourceAsStream("/WEB-INF/testApp.properties"); now testApp.properties is in myapp/WEB-INF/ * - InputStream is = this.getClass().getResourceAsStream("testApp.properties"); - InputStream is = Thread.currentThread().getContextClassLoader(). getResourceAsStream("myservlet.conf"); now, (normally), myservlet.conf/testApp.properties is in myapp/WEB-INF/classes Bo May.29, 2001