You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Oxley <da...@staffplanner.co.uk> on 2000/09/27 18:34:15 UTC

Host name

I need to retrieve the host name of the server on which I am currently
running. I used:
InetAddress.getLocalHost().getHostName();
...but this returns the wrong host if it is a virtual host that took the
HttpRequest.
How can I get the name of the virtual host.
Thanks.
Dave
Dave@Staffplanner.co.uk

RE: Host name

Posted by Mike Bremford <mi...@paperx.com>.
Try request.getServerName(). Haven't tried it, but it's supposed to work.

Cheers... Mike

> -----Original Message-----
> From: David Oxley [mailto:dave@staffplanner.co.uk]
> Sent: 27 September 2000 17:34
> To: tomcat-user@jakarta.apache.org
> Subject: Host name
> 
> 
> I need to retrieve the host name of the server on which I am currently
> running. I used:
> InetAddress.getLocalHost().getHostName();
> ...but this returns the wrong host if it is a virtual host 
> that took the
> HttpRequest.
> How can I get the name of the virtual host.
> Thanks.
> Dave
> Dave@Staffplanner.co.uk
> 

RE: Host name

Posted by Paul FitzPatrick <cp...@fitzpatrick.cc>.
How about trying request.getHEaders or request.getRequestURI

The second will require some parsing, but you should be able to get it from
there.

Regards,
Paul


-----Original Message-----
From: David Oxley [mailto:dave@staffplanner.co.uk]
Sent: Wednesday, September 27, 2000 12:34 PM
To: tomcat-user@jakarta.apache.org
Subject: Host name


I need to retrieve the host name of the server on which I am currently
running. I used:
InetAddress.getLocalHost().getHostName();
...but this returns the wrong host if it is a virtual host that took the
HttpRequest.
How can I get the name of the virtual host.
Thanks.
Dave
Dave@Staffplanner.co.uk