Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CA8F010BB3 for ; Thu, 1 Aug 2013 18:22:06 +0000 (UTC) Received: (qmail 26057 invoked by uid 500); 1 Aug 2013 18:22:03 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 26002 invoked by uid 500); 1 Aug 2013 18:22:03 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 25986 invoked by uid 99); 1 Aug 2013 18:22:02 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Aug 2013 18:22:02 +0000 Received: from localhost (HELO s2laptop.home) (127.0.0.1) (smtp-auth username markt, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Aug 2013 18:22:01 +0000 Message-ID: <51FAA6C5.6010607@apache.org> Date: Thu, 01 Aug 2013 20:19:49 +0200 From: Mark Thomas User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: GetRealPath Alternative for WAR Deployment References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 01/08/2013 17:45, Majors, Jeremy wrote: > I've seen multiple postings online that state that when you deploy a > WAR file rather than using an exploded WAR, then the > request.getServletContext().getRealPath() method returns null. Due > to a requirement by my team lead, I cannot deploy the application in > any other fashion besides a precompiled WAR file (deploying a folder > fixes this issue) and I was using the > request.getServletContext().getRealPath() method so that I could get > the version # of the WAR that I have deployed (ex: myWAR##001.war). > Is there another way to get the version number? I also looked online > to see if there was a way to get the docBase parameter from the > context file, but all the postings for that said to use > request.getServletContext().getRealPath(), which is returning null. > > Any guidance would be greatly appreciated. There are ways via Tomcat internals but they tend to get blocked in production environments. The simplest way is to add a version.properties file to WEB-INF/classes (kept up to date by your build script) with the information you need and access it via the class loader. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org