CFLib.org – Common Function Library Project

GetServerIP()

Last updated January 12, 2004

Version: 1 | Requires: ColdFusion 5 | Library: UtilityLib

 
Rated 2 time(s). Average Rating: 4.0

Description:
This tag is able to get the ip address of your server. This can be used for servers that are in a cluster and you need to know the ipaddress of the computer throwing an error. This will only work for one ip of a machine.

Return Values:
Returns a string.

Example:

view plain print about
<cfoutput>#GetServerIP()#</cfoutput>

Parameters:

No arguments.

Full UDF Source:

view plain print about
<cfscript>
/**
 * Gets the ip address of the server.
 * 
 * @return Returns a string. 
 * @author Robert Everland III (reverland@reactivevision.com) 
 * @version 1, January 12, 2004 
 */

function GetServerIP() {
   var iaclass="";
   var addr="";
      
   // Init class
   iaclass=CreateObject("java""java.net.InetAddress");

   //Get Local host variable
   addr=iaclass.getLocalHost();

   // Return ip address
   return addr.getHostAddress();
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson