0

我正在尝试将 URL 请求从 HTTPS 协议更新为 http [反之亦然]。但是我不确定如何设置我刚刚创建的新请求 URL 并将其传递给下一个 servlet。

代码片段如下,但似乎没有按预期转发。仅当我知道如何更新请求时

    String url = null;
    if (request.getScheme().equals("http")) {
        url = "https://" + request.getServerName()+":8080"+ request.getContextPath() + request.getRequestURIWithQueryString();

    System.out.println ("***************************Handling request for ************************ Remote User " + request.getRemoteUser());
    System.out.println ("***************************Handling request for ************************ Scheme " + request.getScheme());
    System.out.println ("***************************Handling request for ************************ ServerName " + request.getServerName());
    System.out.println ("***************************Handling request for ************************ ContextPath " + request.getContextPath());
    System.out.println ("***************************Handling request for ************************ ServletPath " + request.getServletPath());
    System.out.println ("***************************Handling request for ************************ URI with QueryString " + request.getRequestURIWithQueryString());

    if (request.getPathInfo() != null) {

        System.out.println ("***************************Handling request for ************************ PathInfo " + request.getPathInfo());
        url += request.getPathInfo();
        System.out.println ("***************************Handling request for ************************ URL " + url);
    }




   System.out.println ("***************************Handling request for ************************ URL 2 " + url);

  dispatcher = request.getRequestDispatcher(url);

} 
4

0 回答 0