Solved

HttpServletRequest getServerName returning internal IP address

Posted on 2008-10-08
1
2,430 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 500 total points
ID: 22669901
Look at InetAddress and the getHostName() method. It is supposed to do a reverse lookup for you.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
matchUp  challenge 9 71
scoresSpecial  challenge 13 40
Understanding websocket example in spring 1 42
Java and GPO 11 47
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now