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

  • SEARCH
  • Home
  • 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 6883657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:24:37+00:00 2026-05-27T05:24:37+00:00

If I had an instance of HttpServletRequest , I could do request.getServerName() to get

  • 0

If I had an instance of HttpServletRequest, I could do request.getServerName() to get the server name. However, during the post initialization of the controller beans, I have no instance of HttpServletRequest.

@Controller
@RequestMapping(value = {"/data"})
public class DataController {
    @PostConstruct
    public void init() {
        // how to get server name?
    }
}

How do I get the server name in this case?

  • 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-05-27T05:24:38+00:00Added an answer on May 27, 2026 at 5:24 am

    There are no good ways to do it.

    Generally speaking, server doesn’t know the name that can be used to access it from the outside. Actually, HttpServletRequest.getServerName() isn’t a solution either, because it returns a name used to send that particular request, not the canonical name you want your server to be known under.

    The typical solution is to configure the canonical server name for a particular deployment in a property file, etc.

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

Sidebar

Related Questions

I had to re-install my SQL Server 2005 Express instance due to a conflict
Imagine in the Global.asax.cs file I had an instance class as a private field.
I had used Server Explorer and related tools for graphical database development with Microsoft
I had a problem with updating instance structure which contains repeating nodes. I wanted
I've had a very rarely occurring bug where a key in an NSMutableDictionary instance
Is it possible for a PHP object instance to destroy/unset itself? Say I had
My old iMac G5 died recently. I had a PostgreSQL instance running there, and
Asp.net team had designed script manager such that only one instance existed per page(HttpHandler),
I recently began outbalancing our host instance memory usage because we had a lot
When do I create and close an instance of AssetManager. I had a bug

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.