O'Reilly logo

Sams Teach Yourself J2EE™ in 21 Days by Peter Roxburgh, Andy Longshaw, Debbie Law, Dan Haywood, Martin Bond

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling Errors

There are a number of possible error or failure conditions that need to be handled by your servlet. These errors fall into the following two categories:

  • HTTP errors

  • Servlet exceptions

HTTP Errors

One way of handling HTTP errors in the deployment descriptor has already been briefly mentioned. By using the XML error-page tag, you can ensure that the client is sent an application-specific page when it gets an error. You can use this page to send appropriate information in response to any HTTP error code. The following, for example, replaces the standard HTTP “404 Not found” error page with one that will have been written for this application:

 <error-page> <error-code>404</error-code> <location>/Servlets/error404.html</location> </error-page> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required