wood burning stoves
The moose likes Servlets and the fly likes Getting Domain name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting Domain name" Watch "Getting Domain name" New topic

Getting Domain name

Fawad Ali
Ranch Hand

Joined: Dec 28, 2009
Posts: 115
Hi All,
I want to construct a link back to my site. So how can I get a domain name from the URL. My url looks like something below.

skild2 is the name of the war file deployed at http://devel.skild.com. I am using the following code but I am always getting it as a localhost and not devel.skild.com. I am using the following pieces of codes.


Any ideas on this? Thanks in advance BTW.

Regards, Fawad Ali.
Software Engineer, Stafona Inc. - My Blog
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

Rather than going through all the hoops with the URL class, perhaps there is a more direct approach? Hint: look at the other methods on HttpServletRequest.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Getting Domain name
It's not a secret anymore!