I have an existing Java web application that's using Apache + Tomcat as servers. There's one thing that's been bothering me a lot: tracking NPEs. Obviously if I know where every possible place a NPE could occur then I could catch them all and do an appropriate action (eg. email notification) but this is not possible for programmers. Currently when the app encounters an unexpected NPE, it just stops and the webpage simply displays an ugly error message to site users and developers have no clue of that happening. What I'm trying to achieve here is:
Can Tomcat handle NPE (and also perhaps all kinds of exceptions) by redirecting users to a proper error page and notifying site administrator with an email?