I've seen:
How to set session-timeout, error-pages programmatically without web.xml
and
How to programmatically set error-page and etc web.xml parameters in spring
The first one is however specific to tomcat, and the second has not a good answer, plus it requires Spring.
So is it possible to set the error-page normally defined in web.xml, maybe in an ServletListener or similar.