Within a struts 2 action, how can I determine if a given URL (assumed to be served by the current server) would result in a 404 "not found" result.
Background: For the search box on our site, we use google custom search. Because google doesn't index frequently, we sometimes run into cases where google will return a URL in a search result that now results in a 404 "not found" condition. What I'd like to do is eliminate those results from what I display to the user, without having to reinvent a bunch of parsing, etc, type of logic.
Approaches I've considered:
1) Use Ajax on the client to do a HEAD on each result link and hide/remove those that return a 404. This could be less than perfect for the user as some requests might take a while to process, so link results would visibly disappear, which could be disconcerting.
2) Similar to 1), but do this from the server - essentially making a recursive HEAD call to the server for each link before I include it in the search results.
What I'd really like is something like 2) but without the network overhead.