André Warnier wrote:
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 domainName.com 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.


More precisely :

getRemoteAddr

public java.lang.String getRemoteAddr()

Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.

    Returns:
a String containing the IP address of the client that sent the request

getRemoteHost

public java.lang.String getRemoteHost()

Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST.

    Returns:
        a String containing the fully qualified name of the client


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to