Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8745917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:06:47+00:00 2026-06-13T12:06:47+00:00

The project i am working on have multiple instances(i.e different website) running in single

  • 0

The project i am working on have multiple instances(i.e different website) running in single code base. Based on the URL we show corresponding website.

For example, if http://www.uswebsite.com/ the we show US website. and ifhttp://www.cawebsite.com/ will show Canadian website. The code that is written to detect this is

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

String server` = httpRequest.getServerName();

If request is from the http://www.uswebsite.com/ then according to above code String server = uswebsite so we have additional code written to pop up the corresponding site

we are now planning to include the European instance in the same code base and i see that the URL for the europe site is going to be like this http://www.europewebsite.co.uk/. With getServer() as above will it fetch String server=europewebsite. By having the .co.uk at the end will the above code still get String server=europewebsite or String server=europewebsite.co Please advise as i can’t test it out this in my local.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:06:48+00:00Added an answer on June 13, 2026 at 12:06 pm

    The wording of your question is rather confusing, so I’m assuming that you simply want to extract the hostname from a hierarchical URL string.

    The most reliable way to do it is to construct an instance of java.net.URL or java.net.URI for the url string, and use the relevant getter to extract the hostname.


    On the other hand, if you are trying to detect the virtual hostname for the current request in a servlet, then your httpRequest.getServerName() gives you that hostname as it appears in the first line of the HTTP request (unless something has rewritten it …).


    On the other hand, if you simply want to extract "europewebsite" from a DNS name like "www.europewebsite.co.uk", there is no general solution. I’d recommend converting the DNS to all lowercase and doing a lookup in a table that you have pre-initialized with all of the variations that you are prepared to recognize.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a project I'm working on I will have multiple servers and lots of
I have a project which I am working on and it has multiple files
I have a project which I am working on and it has multiple files
I am working on a project that requires an object to have multiple values.
I am working on a Grails project, its an accounting project. We have multiple
I have an XCode project I am working on that has multiple views controlled
We have multiple developers working on the same unit test project that have unique
I'm working on a project, that have multiple settings on a form, (selections, checkboxes,
I need help. I am working on a project where I have multiple pages
I'm working on a build script with Gradle. We have multiple projects at our

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.