I am using Tomcat 6 (but the same should apply to Tomcat 7). Let's say my web.xml contains this definition:
<error-page>
<error-code>401</error-code>
<location>/Handle401Error.jsp</location>
</error-page>
Suppose I now return HTTP 401 from some other servlet/JSP:
httpResponse.sendError(SC_UNAUTHORIZED, "This is a message");
How can I access the HTTP response text ("This is a message") in Handle401Error.jsp? The way Tomcat does this, when it shows an error page like this

is by using a Valve (ErrorReportValve). Do I need to write a Valve as well?
Edit: the accepted answer below is exactly what I have been looking for, and the assumed duplicate of this question does not mention the same solution.