Return-Path: Delivered-To: apmail-geronimo-user-archive@www.apache.org Received: (qmail 18897 invoked from network); 23 May 2006 19:13:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 23 May 2006 19:13:27 -0000 Received: (qmail 13956 invoked by uid 500); 23 May 2006 19:13:25 -0000 Delivered-To: apmail-geronimo-user-archive@geronimo.apache.org Received: (qmail 13928 invoked by uid 500); 23 May 2006 19:13:25 -0000 Mailing-List: contact user-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: user@geronimo.apache.org List-Id: Delivered-To: mailing list user@geronimo.apache.org Received: (qmail 13917 invoked by uid 99); 23 May 2006 19:13:25 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 May 2006 12:13:25 -0700 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 63.246.7.35 is neither permitted nor denied by domain of bwnoll@gmail.com) Received: from [63.246.7.35] (HELO mail.virtuas.com) (63.246.7.35) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 May 2006 12:13:23 -0700 Received: (qmail 19903 invoked by uid 89); 23 May 2006 19:13:02 -0000 Received: by simscan 1.1.0 ppid: 19860, pid: 19862, t: 8.3273s scanners: clamav: m: spam: 3.0.2 Received: from unknown (HELO ?127.0.0.1?) (bnoll@virtuas.com@168.103.85.139) by smtp.virtuas.com with SMTP; 23 May 2006 19:12:53 -0000 Message-ID: <44735EB2.3040102@gmail.com> Date: Tue, 23 May 2006 13:12:50 -0600 From: Bryan Noll User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 To: user@geronimo.apache.org Subject: Re: How to change the default directory References: <4528855.post@talk.nabble.com> In-Reply-To: <4528855.post@talk.nabble.com> Content-Type: multipart/mixed; boundary="------------010609010403070202010704" X-Antivirus: avast! (VPS 0621-2, 05/23/2006), Outbound message X-Antivirus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on virtuas01.managed.contegix.com X-Spam-Level: X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. --------------010609010403070202010704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Not exactly what you're asking for, but couldn't you do this.... String home = servletConfig..getServletContext().getRealPath("/"); or... check out the attached file. Fran Varin wrote: > We have a web application that reads some Java Properties files when it > initializes. In order to avoid having to code a physical directory path to > the Properties files we would like to use a relative path. > > Also, we would like to keep the Properties files packaged within the WAR > file. When Geronimo comes up its default path ends up being something like: > > c:\apache\geronimo-tomcat-j2ee-1\geronimo-1.0\bin\ (Based on the > windows install directory) > > We have been successful in accomplishing the above using Tomcat since Tomcat > allows the default directory to be configured. Is there a similar > configuration for Geronimo? > > > -- > View this message in context: http://www.nabble.com/How+to+change+the+default+directory-t1670804.html#a4528855 > Sent from the Apache Geronimo - Users forum at Nabble.com. > > > --------------010609010403070202010704 Content-Type: text/plain; name="staticMethods.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="staticMethods.txt" /** * Returns the resource defined by the 'resource' parameter as a * java.io.File object. It is expected that the 'resource' parameter is a * path (either to a directory or file) relative to the classpath. * * If the 'resource' path provided is not relative to the classpath, the * return value will be a non-null java.io.File object whose 'exists()' * method returns false. It is the responsibility of the caller to check * the value of 'exists()', as this method makes no guarantee to return * a File object that exists. * * @param caller - Class object to use in the call to: * caller.getResource(resource) * You should expect a resource you want to use to be loaded by the same * ClassLoader that loaded the classes in your artifact (jar, war, ear, etc.) * * @param resource * @return java.io.File - non-null, may or may not exist, depending on * 'resource' input param */ public static final File getClasspathResource(Class caller, String resource) { File returnFile = null; try { URL url = caller.getResource(resource); if (url != null) { String urlFile = getFileSystemPathFromUrlPath(url.getFile()); if (url != null) { returnFile = new File(urlFile); if (returnFile == null || !returnFile.exists()) { returnFile = new File(resource); } } else { returnFile = new File(resource); } } } catch (Exception ignore) { } return returnFile; } /** * Replaces the http url encoding of a space (%20) with an actual space, * so that if you try to do something like this: * File f = new File(filePathString) * it will be able to locate the file on the file system. * * @see http://www.blooberry.com/indexdot/html/topics/urlencoding.htm * @see http://www.ietf.org/rfc/rfc2396.txt * * @param percent20InsteadOfSpacesString * @return */ public static final String getFileSystemPathFromUrlPath(String percent20InsteadOfSpacesSt String goodString = percent20InsteadOfSpacesString.replaceAll("%20", " "); return goodString; } --------------010609010403070202010704--