Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
anand mohan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
anand mohan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic