I believe, someone out there can solve my problem. I have developed web Java App, this app will process the request base on domain name, the case as follows: (not real domain) www.salesdept.com www.inventory.com www.maintenance.com www.office.com, all of above domain will redirect to my server Java web app
// after googling, I found a code as follows:
public static String getDomainName(String url) throws URISyntaxException { URI uri = new URI(url); String domain = uri.getHost(); return domain.startsWith("www.") ? domain.substring(4) : domain; }
// As we can see, String url needs to specify the value.
Question: How to do it in Java to catch the domain name programatically from incoming hit to my web app?, honestly, I dont have idea how to do it.