How do you properly handle errors encountered in a servlet? Right now, the app that I inherited (uses only plain JSP/Servlet) has a superclass called Controller
Or you can intercept all your exceptions using a servlet:
ErrorServlet
com.domain.MyErrorServlet
ErrorServlet
/error
java.lang.Throwable
/error
Then in the servlet you can handle the exception like this
public class MyErrorServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response){
Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
// You can log the exception, send to email, etc
}
}