Servlet technologies provide a good way to redirect the errors in the web pages. In this section, we will show some cases to do it.
Error mappings
File configuration
An alternative to the annotations is file configuration. Actually, file configuration allows a more complete set of configurations compared to annotations. Firstly, we will see how to configure a servlet through the web.xml file, the default configurator file available in the Java web applications. Take this servlet sample:
public class ErrorMappingServlet extends HttpServlet {
...
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
throw new RuntimeException();
}
...
}
This servlet...