tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: getServerName returns 'localhost'
Date Wed, 03 Mar 2010 13:43:11 GMT
vgud wrote:
> Users use tomcat directly.
> My server responds to different domain names, and I want to know which one
> users use. I try to get domain name by request.getServerName() but instead
> of I get 'localhost'.

Look up the java doc for HttpRequest.
You should probably use remadr = request.getRemoteAddress() or something 
like that. That will give you the IP of the client, not your own IP. 
Then you should use a DNS lookup (I mean the equivalent Java function) 
to translate the remote IP into the corresponding remote name.

request.getServerName() probably gives you the name of your own server 
(the one which is in the <Host> tag of your server.xml config file.

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

View raw message