Reputation: 765
I need to check if a web page hosted on a remote server via tomcat is deployed or not.There may be a case where the page is not deployed and I need to capture this. I've tried with URL connection but I guess that is only useful for verifying if tomcat is up or down on the remote system.
How can I go about verifying whether the page is deployed or not ?
Thanks in advance, Fell
Upvotes: 0
Views: 129
Reputation: 272267
I would use HttpClient and watch for connection and IO exceptions (if the server itself is not responding), and/or the appropriate HTTP status codes (probably you're only looking for a 200). I would perhaps issue a HEAD request, rather than a GET request, to simply get the response headers, and not the full page (although this may be an optimisation too far - how expensive is your page to retrieve?) .
You can configure connection timeouts appropriately and thus determine status in a timely fashion.
Upvotes: 2
Reputation: 10665
URLConnection is the way to go. Look at this example http://nadeausoftware.com/node/73
Upvotes: 1