public static String extractRequestedDomainName(final String requestURL){
  final int domainNameStartIndex=requestURL.indexOf("://") + 3;
  String domainName=requestURL.substring(domainNameStartIndex,requestURL.indexOf('/',domainNameStartIndex));
  if (domainName.contains(":"))   domainName=domainName.split(":")[0];
  return domainName;
}

public static String extractRequestedDomainName ( final String requestURL ) { final int domainNameStartIndex = requestURL . indexOf ( "://" ) + 3 ; String domainName = requestURL . substring ( domainNameStartIndex , requestURL . indexOf ( '/' , domainNameStartIndex ) ) ; if ( domainName . contains ( ":" ) ) domainName = domainName . split ( ":" ) [ 0 ] ; return domainName ; }
this will return only domain name from given requesturl < br / > eg : http : / / www . domain . com / cxt / xyz will return www . domain . com http : / / somehost : 8090 / cxt / xyz will return somehost
