How to get the name of the web server ?

Discussions

Web tier: servlets, JSP, Web frameworks: How to get the name of the web server ?

  1. How to get the name of the web server ? (1 messages)

    Ho to get the name of the server running in a port in a host, for example I
    write a program that scan all the ip address that start from 155.108.000.000
    for the port 80, how to know if the web server that is running is IIS,
    Apache or Tomcat.
    thanks
  2. How to get the name of the web server ?[ Go to top ]

    You can get the server information from the "Server" field in the HTTP response. Use the following code snippet in your program.

    java.net.URL url = new URL("http://www.microsoft.com");
    java.net.URLConnection conn = url.openConnection();
    System.out.println("Server:" + conn.getHeaderField("Server"));

    Of course, you need to catch exceptions. Also, the reported web server(host) information may not be accurate if the host is
    1. using TCP connection-level firewall
    2. using SLB(server load balancing device)
    3. using web proxy cache OR
    4. load balancing with round robin DNS with different operating systems.

    Hope this helps.