THE Waterfall :
So, basically, I am able to create a custom error page using web.xml:
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/pages/error/404.jsp</location>
</error-page>
But so far, in my project, I do not use web.xml and tend to use only java code.
Is there a proper and easy way to do like in web.xml but without using it (create custom error page)? And if there is no such way then would it be a bad move to add web.xml only for handling custom error pages?
THE Waterfall :
Well, as @MarkA.Fitzgerald mentioned in the comments:
The community seems to feel that there is no way to do this according to stackoverflow.com/a/13450154/1840078.
So, I guess, I can live with web.xml doing such simple stuff as creating custom error pages. I find it simple and clean instead of trying to "hardcode" it in java.