Getting the server hostname programmatically

December 02, 2003

Need to know a server's hostname, not the http server name. Try this:
<cfset inet = CreateObject("java", "")>
<cfset inet = inet.getLocalHost()>

Like this? Follow me ↯

7 people found this page useful, what do you think?


why not just use #cgi.server_name#?
That returns different values depending on the web site domain. This method always returns the server's hostname. I'm not sure why you would need that specifically, but someone asked for it, and this is the solution I came up with.
Hi Jason, What I'm using here is part of the standard Java API. Documentation for it can be found here: The service factories in ColdFusion MX are not documented by Macromedia at all, they don't really want you messing with them. When CFMX first came out I posted some undocumentation here: it doesn't cover the service factory, but it does cover some other features.
"documentation out there on Macromedia Java variables and functions" its called fusdocs (Coldfusion MX javadocs)
what is the server hostname for tripod/lycos. i need this info to get my website up which is hosted by tripod and the domain name is sold to me by thanks ruel brown

Foundeo Inc.