Las respuestas anteriores no son 100% claro, así que esto es lo que me ayudó. Tenía una página estática 401.html y experimenté el mismo problema que el póster original. Todo lo que hice fue cambiar la página a 401.página JSP y volcar este derecho en la parte superior:
<%
String realmName = "A nice name to show as the title of on the pop-up";
response.setHeader("WWW-Authenticate","Basic realm=\"" + realmName + "\"");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
%>
El following post on coderanch.com sirvieron como guía.
Así, en pocas palabras, la sección pertinente de web.xml se parece a esto:
<!-- Internal server error. -->
<error-page>
<error-code>500</error-code>
<location>/errors/500.html</location>
</error-page>
<!-- Not found. -->
<error-page>
<error-code>404</error-code>
<location>/errors/404.html</location>
</error-page>
<!-- Unauthorized. -->
<error-page>
<error-code>401</error-code>
<location>/errors/401.jsp</location>
</error-page>
Y 401.jsp se parece a esto:
<%
String realmName = "A nice name to show as the title of on the pop-up";
response.setHeader("WWW-Authenticate","Basic realm=\"" + realmName + "\"");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>401 Unauthorized</title>
<meta name="description" content="The server has not found anything matching the Request-URI.">
<style type="text/css">
body {background-color:ffffff;background-image:url(http://);background-repeat:no-repeat;background-position:top left;background-attachment:fixed;}
h3{font-family:Arial;color:000000;}
p {font-family:Arial;font-size:14px;font-style:normal;font-weight:normal;color:000000;}
</style>
</head>
<body>
<h3>401 Unauthorized</h3>
<p>The request requires authentication.</p>
</body>
</html>
Tomcat no está secuestrando nada, si regreso la página de informe de estado predeterminado, entonces simplemente no lo configuró correctamente Acabo de leer la documentación correcta – Peter
No quiero que tomcat muestre ninguna página de error –