Errorpages for your Java-Application

For a default Java Web-Application there are no error pages defined. During development this has the advantage, that you can see the error message and the complete stack trace. So you can find the source of the error. In our final version we don’t want to display this information, but we need to display a message that an error occurred.

Define error pages

Error pages can be created in your web.xml File. This can be found in your WEB-INF folder. This code defines some error pages for some different kinds of error sources:

First we define error pages for different kinds of error codes. For this I have created HTML error pages. There files are in a subdirectory of WEB-INF. The last error page is very important. If an error occurred that was not covered with an error page, than we want to display a default error page. If we forget this, it can happen, that an unknown error displays error code and a stack trace.

(Visited 63 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *