• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie : Obtain the name of a server in Java
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Community Wish List
  • Next by Date: Checking the validity of a session from its ID
  • Previous by thread: Re: Newbie : Obtain the name of a server in Java
  • Next by thread: Re: Newbie : Obtain the name of a server in Java
  • Index(es):
    • Date
    • Thread