You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2009/06/09 04:47:57 UTC

T5: getting domain name

Hi,

 using Request getServerName, it returns 'www.example.com' or 'example.com'
depending on the url, what is the function that will return only the domain
name? in this case example.com.

Thanks,
-- 
View this message in context: http://www.nabble.com/T5%3A-getting-domain-name-tp23935537p23935537.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: getting domain name

Posted by Robert Zeigler <ro...@scazdl.org>.
Although it's true that domain.com is the top level domain, and www.domain.com 
  is a subdomain of domain.com, they are still both valid domains and  
potentially point to different servers.  Accordingly, they should be  
treated separately.  If they should really be treated the same, I  
suggest using apache to do appropriate url rewriting/forwarding so  
that requests to domain.com are always sent to www.domain.com (or vice  
versa, but typically domain.com is rewritten to www.domain.com).   
Alternatively, you could use the URLRewriting support built into  
tapestry 5.1 to do ensure that your application always sees one or the  
other domain, and that all links are written accordingly.

Although www.domain.com and domain.com often point to the same server,  
there's no reason they have to.  www is just another subdomain (albeit  
with a standard implication).  Would you want to ignore the difference  
between appA.domain.com and appB.domain.com?


Robert

On Jun 8, 2009, at 6/89:47 PM , Angelo Chen wrote:

>
> Hi,
>
> using Request getServerName, it returns 'www.example.com' or  
> 'example.com'
> depending on the url, what is the function that will return only the  
> domain
> name? in this case example.com.
>
> Thanks,
> -- 
> View this message in context: http://www.nabble.com/T5%3A-getting-domain-name-tp23935537p23935537.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: getting domain name

Posted by "Craig St. Jean" <cr...@gmail.com>.
Hello,
Knowing that the format will always be [anything.]domain[.tld], can't you
just check if any periods exists?  If 0 or 1, you can just use what the
method returned, otherwise just substring it.

On Mon, Jun 8, 2009 at 10:47 PM, Angelo Chen <an...@yahoo.com.hk>wrote:

>
> Hi,
>
>  using Request getServerName, it returns 'www.example.com' or 'example.com
> '
> depending on the url, what is the function that will return only the domain
> name? in this case example.com.
>
> Thanks,
> --
> View this message in context:
> http://www.nabble.com/T5%3A-getting-domain-name-tp23935537p23935537.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>