Re: Dead Hyperlinks - How do you check for them in advance
Re: Dead Hyperlinks - How do you check for them in advance
- Subject: Re: Dead Hyperlinks - How do you check for them in advance
- From: Patrick Robinson <email@hidden>
- Date: Thu, 29 Jul 2004 08:48:56 -0400
On Jul 29, 2004, at 8:10 AM, Jonathan Fleming wrote:
How does one check in advance for dead links so that a WOHyperlink can
be turned off if this proves to be true?
Here is some code I've used (HttpURLConnection is in java.net):
public static boolean isValid(String url) {
try {
HttpURLConnection c = (HttpURLConnection)new
URL(url).openConnection();
c.setRequestMethod("HEAD");
return (c.getResponseCode() == HttpURLConnection.HTTP_OK);
} catch (IOException e) {
return false;
}
}
--
Patrick Robinson
AHNR Info Technology, Virginia Tech
email@hidden
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.