Ashraf Jabnoun
Ashraf Jabnoun

Reputation: 21

How to test the Availability of http and https servers in java

I need a solution for testing the availability of http and https servers. For example: I need to know if servers (apache and tomcat) are available or not.

I don't need to consume inputstream, just display a green button if it works or red if it doesn't.

Upvotes: 0

Views: 393

Answers (1)

Vartlok
Vartlok

Reputation: 2589

You can use URLConnection to check that your server is up. More about it:

Using java.net.URLConnection to fire and handle HTTP requests

Or HttpsUrlConnection:

http://www.mkyong.com/java/java-https-client-httpsurlconnection-example/

If connection return 200, then server is working.

Upvotes: 1

Related Questions