The guy surfing your site doesn’t want to see your stack trace. And he’s not too thrilled to get a standard “404 Not Found”, either.
You can’t prevent all errors, of course, but you can at least give the user a friendlier (and more attractive) error response page. You can design a custom page to handle errors, then use the page directive to configure it.
The designated ERROR page (“errorPage.jsp”)
The BAD page that throws an exception (“badPage.jsp”)
What happens when you request “badPage.jsp”
You can declare error pages in the DD for the entire web app, and you can even configure different error pages for different exception types, or HTTP error code types (404, 500, etc.).
The Container uses <error-page> configuration in the DD as the default, but if a JSP has an explicit errorPage page directive, the Container uses the directive.