permaculture playing cards*
The moose likes JSP and the fly likes How can I redirect to an ERROR message page when server is down? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How can I redirect to an ERROR message page when server is down?" Watch "How can I redirect to an ERROR message page when server is down?" New topic
Author

How can I redirect to an ERROR message page when server is down?

anand mohan
Greenhorn

Joined: Oct 09, 2000
Posts: 7
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.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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.


42
anand mohan
Greenhorn

Joined: Oct 09, 2000
Posts: 7
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."
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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
anand mohan
Greenhorn

Joined: Oct 09, 2000
Posts: 7
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.
eammon bannon
Ranch Hand

Joined: Mar 16, 2004
Posts: 140

Once the server is down there is no response to the browser.

No 403, 404, 500 etc.? So you do mean when the webserver that is serving your app fails you still want to be able to redirect? This is impossible.
anand mohan
Greenhorn

Joined: Oct 09, 2000
Posts: 7
Yes you correct. Once the server is down browser won't get any response.
Is there a way to handle this one using proxy server?
 
 
subject: How can I redirect to an ERROR message page when server is down?