Re: Newbie : Obtain the name of a server in Java
Re: Newbie : Obtain the name of a server in Java
- Subject: Re: Newbie : Obtain the name of a server in Java
- From: email@hidden
- Date: Thu, 7 Sep 2006 22:19:46 +1200
/**
* Attempts to establish the host of an incomming request.
* That means the hostname of the request that landed up
* making the request we are experiencing in this context.
*/
public static String getExternalHostnameFromInboundRequest
(WORequest request)
{
String httpHostHdr = request.headerForKey("http_host");
if((null!=httpHostHdr) && (0!=httpHostHdr.length()))
return httpHostHdr.trim();
String hostHdr = request.headerForKey("host");
if(null!=hostHdr)
{
int indexOfColon = hostHdr.indexOf(':');
if(-1!=indexOfColon)
return hostHdr.substring(0,indexOfColon).trim();
return hostHdr.trim();
}
String serverNameHdr = request.headerForKey("server_name");
if((null!=serverNameHdr) && (0!=serverNameHdr.length()))
return serverNameHdr.trim();
return null;
}
___
Andrew Lindesay
www.lindesay.co.nz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden