• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic