Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 76465 invoked by uid 500); 4 Apr 2001 11:22:38 -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 76458 invoked from network); 4 Apr 2001 11:22:37 -0000 Received: from unknown (HELO gyl.gyldan.com) (207.8.29.251) by h31.sny.collab.net with SMTP; 4 Apr 2001 11:22:37 -0000 Received: from gomolka (hst33-21.ltcable.com [64.132.33.21] (may be forged)) by gyl.gyldan.com (8.9.3/8.9.3) with SMTP id GAA04800 for ; Wed, 4 Apr 2001 06:18:53 -0500 Content-Type: text/plain; charset="iso-8859-1" From: Ed Gomolka To: tomcat-user@jakarta.apache.org Subject: Re: How to get around a tricky situation. Date: Wed, 4 Apr 2001 05:22:54 -0500 X-Mailer: KMail [version 1.2] References: <000901c0bc49$9c3d4730$1e00a8c0@Popware.com> In-Reply-To: <000901c0bc49$9c3d4730$1e00a8c0@Popware.com> MIME-Version: 1.0 Message-Id: <01040405225401.05967@gomolka> Content-Transfer-Encoding: 8bit X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N On Tuesday 03 April 2001 09:23, Alex Colic wrote: > Hi, > > I need some advice on how I might fix a problem with one of our web apps. > We farmed out an app that works ok except that the web pages which are > created by servlets are looking for images in the tomcat root images > directory. This presents a problem in that if I create a war of our app I > also have to distribute and copy the images over to the root images > directory. > > Can I set up my web.xml file so that when a web page looks for an image in > the /images directory it actually pulls them out of my myWebApp/images > directory. > You best bet is to change your source code to pick up the path dynamically. You can use something like the following to determine the image path relative to the base of your context: ============ public void init(ServletConfig config) throws ServletException { super.init(config); servletContext = config.getServletContext(); String contextPath = servletContext.getRealPath("/"); String imagesDirectory = contextPath + "images"; } -- Ed Gomolka (egomolka@gyldan.com)