Is it possible to modify the 401 response tomcat'a?

Need to add multiple headers in the 401 error. Is it possible somehow to do this?
Tried using filter:
<filter>
<filter-name>Filter</filter-name>
<filter-class>com.example.filter.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>Filter</filter-name>
<url-pattern>/*</url-pattern>
 </filter-mapping>


but it do not have treatment.

Use BASIC authentication.
July 8th 19 at 15:32
1 answer
July 8th 19 at 15:34
Solution
If I understand correctly, in web.xml add
<error-page>
<error-code>401</error-code>
<location>/errors/401.jsp</location>
</error-page>

After that, all with a 401 will attempt to be redirected to my error page, however, because not authorized, then access will not receive, for this is
in your jsp add:
response.addHeader("WWW-Authenticate", "BASIC realm=\"YOUR-REALM\"");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);

where the realm name is the same as that in web.xml

Find more questions by tags JavaTomcat