if (filterProcessesUrl.equals(httpRequest.getServletPath())) {
if (httpRequest.getRequestURL().toString().endsWith(httpRequest .getContextPath() + filterProcessesUrl)) {
    public void doFilter(ServletRequest request, ServletResponse response,        FilterChain chain) throws IOException, ServletException {        if (!(request instanceof HttpServletRequest)) {            throw new ServletException("Can only process HttpServletRequest");        }        if (!(response instanceof HttpServletResponse)) {            throw new ServletException("Can only process HttpServletResponse");        }        HttpServletRequest httpRequest = (HttpServletRequest) request;        HttpServletResponse httpResponse = (HttpServletResponse) response;        if (filterProcessesUrl.equals(httpRequest.getServletPath())) {            if (logger.isDebugEnabled()) {                logger.debug("Request is to process authentication");            }            Authentication authResult;            try {                authResult = attemptAuthentication(httpRequest);            } catch (AuthenticationException failed) {                // Authentication failed                if (logger.isDebugEnabled()) {                    logger.debug("Authentication request failed: "                        + failed.toString());                }                httpRequest.getSession().setAttribute(ACEGI_SECURITY_LAST_EXCEPTION_KEY,                    failed);                httpRequest.getSession().setAttribute(HttpSessionIntegrationFilter.ACEGI_SECURITY_AUTHENTICATION_KEY,                    null);                httpResponse.sendRedirect(httpResponse.encodeRedirectURL(httpRequest                        .getContextPath() + authenticationFailureUrl));                return;            }            // Authentication success            if (logger.isDebugEnabled()) {                logger.debug("Authentication success: " + authResult.toString());            }            httpRequest.getSession().setAttribute(HttpSessionIntegrationFilter.ACEGI_SECURITY_AUTHENTICATION_KEY,                authResult);            String targetUrl = (String) httpRequest.getSession().getAttribute(ACEGI_SECURITY_TARGET_URL_KEY);            httpRequest.getSession().setAttribute(ACEGI_SECURITY_TARGET_URL_KEY,                null);            if (targetUrl == null) {                targetUrl = httpRequest.getContextPath() + defaultTargetUrl;            }            if (logger.isDebugEnabled()) {                logger.debug(                    "Redirecting to target URL from HTTP Session (or default): "                    + targetUrl);            }            httpResponse.sendRedirect(httpResponse.encodeRedirectURL(targetUrl));            return;        }        chain.doFilter(request, response);    }