views:

69

answers:

2

Hi,

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

+2  A: 

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.

Brian Agnew
+1  A: 

URLConnection is the way to go. Look at this example http://nadeausoftware.com/node/73

Simon Groenewolt