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:
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> ...