tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Johanson <brad.johan...@gmail.com>
Subject Re: Finding Server URL?
Date Fri, 24 Jun 2005 06:50:47 GMT
On 6/23/05, Michael Jouravlev <jmikus@gmail.com> wrote:
>
> On 6/23/05, Brad Johanson <brad.johanson@gmail.com> 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).
> 
> 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=InetAddress.getLocalHost().getHostAddress();

This is what I'm actually doing right now to get the main IP/DNS. 
What it doesn't give me is the port on which tomcat is listening. 
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


Mime
View raw message