public String getServerName ( ) { if ( WCCustomProperties . CHECK_REQUEST_OBJECT_IN_USE ) { checkRequestObjectInUse ( ) ; } String sName = this . _request . getServerName ( ) ; // if (sName == null || sName.equalsIgnoreCase("localhost")) if ( sName == null || sName . length ( ) == 0 ) { try { // get a real name for the local machine sName = InetAddress . getLocalHost ( ) . getHostName ( ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { //306998.15 logger . logp ( Level . FINE , CLASS_NAME , "getServerName" , "using InetAddress --> " + sName ) ; } } catch ( Throwable th ) { // not much we can do here...just return what we have } } // Begin 255189, Part 2 if ( sName . charAt ( 0 ) != ' ' && sName . indexOf ( ' ' ) != - 1 ) sName = "[" + sName + "]" ; // End 255189, Part 2 if ( TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { //306998.15 logger . logp ( Level . FINE , CLASS_NAME , "getServerName" , "serverName --> " + sName ) ; } return sName ; }
Returns the host name of the server that received the request . Same as the CGI variable SERVER_NAME .