Hi In My application I need to redirect to an ERROR message page if the web server is down/crashed? Is there a way to handle this problem. Kindly help me in this regard. Thanks & Regards Anand.
I hope for you that you mean that you want to give an error if a remote server is down? As your JSP runs inside your webserver you cannot have it redirect to an errorpage if the webserver is down because the request would never lead to the JSP being executed if the server is down because the server doesn't get the request because it is down. For a remote server, you can check the HTTP return code from a request to the server and raise an error if it's not in the 200 range.
Thanks for your response. Can you eloborate about this."For a remote server, you can check the HTTP return code from a request to the server and raise an error if it's not in the 200 range."
When you do an HTTP request to a webserver, it sends back (as part of the response headers) a status code. This status code is normally 200. You're probably familiar with 404 (file not found), 403 (not allowed), and 500 (internal server error). All those are errors you can trap. Likewise, you should be able to define some means to determine that a server is not responding at all (possibly a timeout trying to talk to it could be used for that). Look into HttpURLConnection
Hi Thanks For your response. Once the server is down there is no response to the browser. I think we can't find timeout. Kindly let me know is there a way to find the time out in the browser.