To do it quickly and portably, you can check for a page if it's served by the server.
For example you can:
boolean isAlive = true;
try {
URL hp = new URL("http://yourserver/TestPage.html");
URLConnection hpCon = hp.openConnection();
// add more checks...
} catch (Exception e) {
isAlive = false;
}
This not much sophisticated method will work with every http server.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…