Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 61994 invoked from network); 21 Dec 2005 17:17:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Dec 2005 17:17:59 -0000 Received: (qmail 54089 invoked by uid 500); 21 Dec 2005 17:17:41 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 53886 invoked by uid 500); 21 Dec 2005 17:17:40 -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 53872 invoked by uid 99); 21 Dec 2005 17:17:39 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Dec 2005 09:17:39 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=NO_REAL_NAME,SUBJ_HAS_SPACES X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [141.228.156.166] (HELO oplss0036.barcap.com) (141.228.156.166) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Dec 2005 09:17:38 -0800 Received: from oplss0036.barcap.com (localhost [127.0.0.1]) by oplss0036.barcap.com (8.12.10/8.11.4) with ESMTP id jBLH4Xrm017707 for ; Wed, 21 Dec 2005 17:04:33 GMT Received: from ldnpsmeg015.INTRANET.BARCAPINT.COM (ldnpsmeg015.nat.barcapint.com [172.23.1.205]) by oplss0036.barcap.com (8.12.10/8.11.4) with ESMTP id jBLH4XOc017691 for ; Wed, 21 Dec 2005 17:04:33 GMT Received: from ldnpsmeh001.INTRANET.BARCAPINT.COM (unverified) by ldnpsmeg015.INTRANET.BARCAPINT.COM (Content Technologies SMTPRS 4.3.10) with ESMTP id for ; Wed, 21 Dec 2005 17:17:15 +0000 Received: from LDNPCMEU302VEUA.INTRANET.BARCAPINT.COM ([10.65.87.30]) by ldnpsmeh001.INTRANET.BARCAPINT.COM with Microsoft SMTPSVC (5.0.2195.6713) ; Wed, 21 Dec 2005 17:17:07 +0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Subject: RE: ServletContextListener - how to detect http path of web application? Date: Wed, 21 Dec 2005 17:17:06 -0000 Message-ID: <2DF66B61F300C247ACF5F407088D80B10DD7F8@LDNPCMEU302VEUA.INTRANET.BARCAPINT.COM> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: ServletContextListener - how to detect http path of web application? Thread-Index: AcYGUCCgiA+n4S8iQlOuXn2i8RC9KgAAQrOQ From: To: X-OriginalArrivalTime: 21 Dec 2005 17:17:07.0496 (UTC) FILETIME=[5ED85A80:01C60652] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Thanks, I might try that. I already made a javax.servlet.Filter, that catches the first request to the server, calls HttpServletRequest.getContextPath(), and stores the result. Of course the Filter actually gets hit on *every single request* to the server. You might call it a brute force solution :-) Iain -----Original Message----- From: Frank W. Zammetti [mailto:fzlists@omnytex.com]=20 Sent: 21 December 2005 17:00 To: Tomcat Users List Cc: Tomcat Users List Subject: Re: ServletContextListener - how to detect http path of web application? Tim is right, you can't do it directly. You *might* be able to construct it in a roundabout way though... Let's assumg you know the method, http vs. https, and its always one or the other. Let's also assume that the element in web.xml names the application context (i.e., if the URL is http://myserver/myapp, then myapp. I believe the following (without actually trying it) would work... String s =3D "http://"; s +=3D new InetAddress.getHostName(); s +=3D "/" + servletContext.getServletContextName(); Kind of hack solution, but it might be OK for your application (assuming it actually works!) --=20 Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: fzammetti@hotmail.com On Wed, December 21, 2005 6:22 am, Tim Funk said: > There is no way to detect the contextPath on servletInit. It can only=20 > be done after the first request. (Using=20 > HttpServletRequest.getContextPath()) > > > -Tim > > Iain.Shepherd@barclayscapital.com wrote: >> Hi, >> >> Apols for a newbie question, I didn't have much luck with the=20 >> archives or in Google. >> >> In my ServletContextListener.contextInitialized method, I need to=20 >> detect the public http path of my web app. i.e.=20 >> http://servername/approot/ >> >> How can I do this? >> event.getServletContext().getResource("/") gives me=20 >> "jndi:/localhost/", not very helpful. >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org ------------------------------------------------------------------------ For more information about Barclays Capital, please visit our web site at http://www.barcap.com. Internet communications are not secure and therefore the Barclays=20 Group does not accept legal responsibility for the contents of this=20 message. Although the Barclays Group operates anti-virus programmes,=20 it does not accept responsibility for any damage whatsoever that is=20 caused by viruses being passed. Any views or opinions presented are=20 solely those of the author and do not necessarily represent those of the=20 Barclays Group. Replies to this email may be monitored by the Barclays=20 Group for operational or business reasons. ------------------------------------------------------------------------ --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org