Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@www.apache.org Received: (qmail 56878 invoked from network); 24 Jun 2005 06:51:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Jun 2005 06:51:11 -0000 Received: (qmail 62715 invoked by uid 500); 24 Jun 2005 06:50:51 -0000 Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 62600 invoked by uid 500); 24 Jun 2005 06:50:51 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 62554 invoked by uid 99); 24 Jun 2005 06:50:50 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Jun 2005 23:50:50 -0700 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=NORMAL_HTTP_TO_IP,RCVD_BY_IP X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of brad.johanson@gmail.com designates 64.233.184.192 as permitted sender) Received: from [64.233.184.192] (HELO wproxy.gmail.com) (64.233.184.192) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Jun 2005 23:50:50 -0700 Received: by wproxy.gmail.com with SMTP id 69so785096wra for ; Thu, 23 Jun 2005 23:50:47 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=nNh+Q0Eo1EXOqYMvlmpCveUiISe4GInQhphP8YQtlJ1clEhy/oGmk9J8V1xPvQiOstIM3i8k1MUwkX0pAFLrA2XzTtwe0IksJysSuL3izSgANABJhfd4LdivMtDJ2wJEY2AD5uDuJC/ASqXh1cc+v4ypO3AjVCNm+swWPFkepkg= Received: by 10.54.143.4 with SMTP id q4mr1653747wrd; Thu, 23 Jun 2005 23:50:47 -0700 (PDT) Received: by 10.54.70.10 with HTTP; Thu, 23 Jun 2005 23:50:47 -0700 (PDT) Message-ID: Date: Thu, 23 Jun 2005 23:50:47 -0700 From: Brad Johanson Reply-To: Brad Johanson To: Michael Jouravlev Subject: Re: Finding Server URL? Cc: Tomcat Developers List In-Reply-To: <1db11534050623153037352e4b@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <1db11534050623153037352e4b@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On 6/23/05, Michael Jouravlev wrote: > > On 6/23/05, Brad Johanson wrote: > > The problem I'm > > running into is how the singleton can find the root URL/server URL > > (and port) for the Tomcat server in which it is running (for example, > > http://167.7.9.95:8080 or http://www.foo-co.com). >=20 > Maybe InetAddress can help you? Thank you for the suggestion. That will give me an IP address for the machine (and DNS name if there is one) of one of the interfaces on the machine (the primary?). Like so: String IP=3DInetAddress.getLocalHost().getHostAddress(); This is what I'm actually doing right now to get the main IP/DNS.=20 What it doesn't give me is the port on which tomcat is listening.=20 That is specified in the conf/server.xml file, but I can't figure out how to access that information from within the servlet code. For now I'm passing it in as a system property, but this is not very elegant or portable. It would be nicer to just be able to ask Tomcat directly since it is already configured somewhere in the tomcat active state. -Brad --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org