@Override
    protected boolean onAccessDenied(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException {

        //just redirect to the specified port:
        int port = toPort(mappedValue);

        String scheme = getScheme(request.getScheme(), port);

        StringBuilder sb = new StringBuilder();
        sb.append(scheme).append("://");
        sb.append(request.getServerName());
        if (port != DEFAULT_HTTP_PORT && port != SslFilter.DEFAULT_HTTPS_PORT) {
            sb.append(":");
            sb.append(port);
        }
        if (request instanceof HttpServletRequest) {
            sb.append(WebUtils.toHttp(request).getRequestURI());
            String query = WebUtils.toHttp(request).getQueryString();
            if (query != null) {
                sb.append("?").append(query);
            }
        }

        WebUtils.issueRedirect(request, response, sb.toString());

        return false;
    }
Redirects the request to the same exact incoming URL, but with the port listed in the filter's configuration.

@param request     the incoming <code>ServletRequest</code>
@param response    the outgoing <code>ServletResponse</code>
@param mappedValue the config specified for the filter in the matching request's filter chain.
@return {@code false} always to force a redirect.
web/src/main/java/org/apache/shiro/web/filter/authz/PortFilter.java