Hi, On 17.03.2010 15:27, Justin Edelson wrote: > On 3/17/10 10:16 AM, Felix Meschberger wrote: >> Hi, >> >> On 17.03.2010 15:09, Justin Edelson wrote: >>> On 3/17/10 9:49 AM, Felix Meschberger wrote: >>>>> String host = request.getHeader("Host"); >>>> >>>> (NB this is what request.getServerName() reports; I would prefer to use >>>> the API) >>> (I seem to recall running into trouble with request.getServerName() and >>> CDNs, so I just got into the habit of using the Host header.) >> >> Just curious: would that be formatting issues which the servlet >> container could not resolve correctly ? > This is what I remember: > > With our CDN at the time, where: > CDN ----> Web Server ----> App Server > > User requested www.site.com, CDN requested origin.www.site.com. > > request.getServerName() = origin.www.site.com > request.getHeader("Host") = www.site.com
Strange. This hints at a servlet container issue, because the getServerName method is defined to: Returns the host name of the server to which the request was sent. It is the value of the part before ":" in the <code>Host</code> header, if any, or the resolved server name, or the server IP address. So, the Host header should really be preferred.... Anyway ... Regards Felix > > Justin > >> >> Regards >> Felix > >