sendRedirect and 404 Page not found

I was wondering if there is a way to first determine if the page exists in a response.sendRedirect(strURL);

first. If the page does not exist then display another page stating why the page does not exist.

Example. Page not found, please try again when processing has completed. I tried using this but it does not work:

try {

response.sendRedirect(strURL);

}

catch(IOException ex) {

response.sendRedirect(strURL2);

}

In this situtaion I am first trying to redirect to a page that may not be ready there yet on the C:\drive.

Thanks

[613 byte] By [joepriv1] at [2007-9-26 3:33:20]
# 1
you can check if(file.exists()){send.redirect(file)}else{}
priviet at 2007-6-29 12:01:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

I don't think an IOException getting raised means that the URL is not found.

One way to do this is...

java.net.URL potentiallyNonExistantPage = new java.net.URL(strURL);

java.net.HttpURLConnection httpConnection = (java.net.HttpURLConnection) potentiallyNonExistantPage.openConnection();

int responseCode = httpConnection.getResponseCode()

if(responseCode == 404) {

response.sendRedirect(strURL2);

} else {

response.sendRedirect(strURL);

}

neville_sequeira at 2007-6-29 12:01:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...