Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HttpServletRequest getServerName returning internal IP address

Posted on 2008-10-08
1
Medium Priority
?
2,611 Views
Last Modified: 2013-11-24
public String getWebrootUrl() {
            if (webrootUrl.length() == 0) {
                  HttpServletRequest request = FacesUtils.getRequest();
                  if (request != null) {
                        try {
                              URL reconstructedURL = new URL(request.getScheme(),
                                          request.getServerName(),
                                          request.getServerPort(),
                                          getWebroot());
                              webrootUrl = reconstructedURL.toString();
                        } catch (MalformedURLException e) {
                              webrootUrl = "";
                        }
                  }
            }
            return webrootUrl;
      }

The above code is use to generate the correct url when we were using a virtual name-based server, we've since moved off using named-based and switched to an IP based scheme so instead of returning somehting like https://www.myurl.com/ it now returns https://192.168.200.10 on our production server which is obviously a private network IP! Is there a way to get code to do a reverse-lookup on the IP in the local /etc/hosts file?

0
Comment
Question by:mhp2007
1 Comment
 
LVL 1

Accepted Solution

by:
Jorge Fraser earned 2000 total points
ID: 22669901
Look at InetAddress and the getHostName() method. It is supposed to do a reverse lookup for you.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question