response.sendRedirect - check redirect is up

Posted by Trick on Stack Overflow See other posts from Stack Overflow or by Trick
Published on 2010-05-31T07:52:14Z Indexed on 2010/05/31 9:32 UTC
Read the original article Hit count: 199

Filed under:
|
|
|

From JSP I just want a redirect to another page...

<% response.sendRedirect("http://www.google.com/"); %>

Can I check if google.com is up and then redirect (or write a msg else)...

Something like that:

<% if(ping("www.google.com")) {
     response.sendRedirect("http://www.google.com/");
} else {
     // write a message 
}%>

Or

<% try {
     response.sendRedirect("http://www.google.com/");
} catch(SomeException e) {
     // write a message 
}%>

It is just an JSP page, I don't have any libraires available (like ApacheCommons for http GET methods).

© Stack Overflow or respective owner

Related posts about java

Related posts about jsp