The output of this program is something like this:
package whataretheyrunning;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author octav
*/
public class SnoopURL {
String URLString = null;
public SnoopURL(String URLString) {
this.URLString = URLString;
}
public void snoop() {
try {
// build URL
URL url = new URL(URLString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET"
conn.setDoOutput(true);
// start talking
conn.connect();
// int length = conn.getContentLength();
// System.out.println(" **** the length of the content is " + length + " for URL " + URLString);
System.out.println(" **** Server type is: " + conn.getHeaderField("Server"+ "\n\n"
;
// get more information
Map map = conn.getHeaderFields();
for (int i = 0; i < map.size(); i++) {
System.out.println(" **** " + conn.getHeaderField(i));
}
// cleanup
conn.disconnect();
} catch (MalformedURLException ex) {
Logger.getLogger(SnoopURL.class.getName()).log(Level.SEVERE, null, ex);
} catch (java.io.IOException ioe) {
ioe.printStackTrace();
} finally {
// do whatever cleanup ...
}
}
@Override
protected void finalize() throws Throwable {
super.finalize();
}
@Override
public String toString() {
return super.toString();
}
}
**** Server type is: Sun-Java-System-Web-Server/6.1
**** HTTP/1.1 200 OK
**** Sun-Java-System-Web-Server/6.1
**** Mon, 18 Feb 2008 04:46:48 GMT
**** text/html;charset=UTF-8
**** policyref="http://www.sun.com/p3p/Sun_P3P_Policy.xml", CP="CAO DSP COR CUR ADMa DEVa TAIa PSAa PSDa CONi TELi OUR SAMi PUBi IND PHY ONL PUR COM NAV INT DEM CNT STA POL PRE GOV"
**** Servlet/2.4,JSP/2.0
**** chunked
**** Starload=star-fep5; Path=/
Now let's look at some popular websites.
Sun's www.sun.com is using the old Web Enterprise server, version 6.1 (the same is true for java.sun.com). The site the publishes this blog: blogs.sun.com is powered by Sun-Java-System-Web-Server/7.0 (a newer version of the same web server). Google seems to use their own version: gws. Yahoo does not tell you (returns null). Microsoft eats their own dog food: Microsoft-IIS/7.0. Nice. IBM runs something called: IBM_HTTP_Server (I bet is Apache's web server).
;
, get a Thread dump.