Introduction
When developing RESTful applications using Java Backend, sooner or later you’ll face with the necessity of handling HTTP errors in a custom way. For example, frontend may require some kind of generic representation of an HTTP error (usually in JSON format), so that it can easily apply a single logic on it.
In Java Backend world, the most popular technology for handling HTTP requests is Java Servlets. It perfectly suits for handling general HTTP requests as well as static resources. RESTful API, on the other hand, is usually handled by another technology, called JAX-RS.
In this article we are going to implement the custom HTTP error handling mechanism for both Java Servlets and JAX-RS technologies.