In JSPs, you may use response.sendError(int code, String message)
to return a particular error code (eg 404 for not found) and a message as well.
These messages display fine, as long as you use the default ugly Tomcat error pages. However, if you create a custom error page, how do you get that message?
I've tried exception.getMessage()
or pageContext.getErrorData()
but no avail. I've been searching for this for like hours and nobody seems to even wonder about the same thing! :S
I forgot to mention I've only tried it with 404s so far, since that's what I need most... The exception is null for some reason, so trying anything on it throws a NullPointerException. The error page is a 404 error page, set via web.xml (since I want it to be displayed for EVERY single 404 error) and for anyone wondering, yes it has the isErrorPage directive set to true...