tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Johanson <>
Subject Re: Finding Server URL?
Date Fri, 24 Jun 2005 06:50:47 GMT
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,
> > or
> 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.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message