How to change the answer before submitting

Is it possible to intercept the sending of the response to the client and send the modified response in the final? I want to remove the "WWW-Authenticate" header from the Basic Auth response, or change the error code from 401 to 403 in the wrong authentication case. Postscript I have the same problem: http://www.java.net/forum/topic/glassfish/glassfish/suppress-www-authenticate-header-if-basic-auth-fails

0


source to share


1 answer


I tried using a filter with HttpServletResponseWrapper, but my Filter was never called before JAAS Basic HTTP Authentication. I solved my annoying popup problems with the following code

In web.xml:

<error-page>
    <error-code>401</error-code>
    <location>/error.jsp</location>
</error-page>

      



error.jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <%
        int status = response.getStatus();
        if (status == 401) {
            response.setStatus(403);
        }
        %>
    </body>
</html>

      

0


source







All Articles