0

i tried to handle the error code 503 in my application web.xml as follows:

<error-page>
   <error-code>503</error-code>
   <location>/serviceNotAvailable</location>
   </error-page>

but it's not working i don't know why, please advise. i am using apache,tomcat.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498
  • What exactly does not work? Does the server not display **/serviceNotAvailable**? What resource is mapped to **/serviceNotAvailable**, a servlet, jsp, etc.? – home Jul 13 '11 at 17:53
  • when 503 occurs, user is not forwarded to the serviceNotAvailable page, btw /serviceNotAvaiable is a jsp page mapped to a spring controller. and btw too above works fine with error code 400 – Mahmoud Saleh Jul 13 '11 at 20:54
  • how are you testing a 503? overloading your server? – JoseK Jul 18 '11 at 09:44
  • stopping and starting tomcat quickly without no sleeping time between shutdown and start – Mahmoud Saleh Jul 20 '11 at 20:23
  • but if you shut down your tomcat, then who will serve the /serviceNotAvailable page? It wont work at all. and if tomcat is running up does the logs show a 503 occured or you get on browser? – JoseK Jul 21 '11 at 06:12

1 Answers1

1

I was in similar situation and end up using apache in front of tomcat.

Ie when tomcat is down from some reason, Apache intercept the 503, and use httpd config

Error Document 503 

to redirect to your own custom page. Some details can be found here apache tomcat 503 custom error page.

503 is quite serious compared to 404 etc, most of time there are some un-recoverable error which crash the service/app, in our case heap-memory issues.

I would also be quite interested in anyone else comes up with how to redirect 503 from Tomcat alone.

Community
  • 1
  • 1
Will
  • 900
  • 10
  • 20