<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    weidagang2046的專欄

    物格而后知致
    隨筆 - 8, 文章 - 409, 評論 - 101, 引用 - 0
    數(shù)據(jù)加載中……

    What's the difference between "redirect" & "forward" in servelt?

    Suppose you have a servlet that just does another redirect to another URL:

    protectedvoid doGet(HttpServletRequest request, HttpServletResponse response)
    {
      response.sendRedirect("/anotherURL");
    }


    This servlet is accessible through the URL /redirectServlet.

    When the client browser makes a request for /redirectServlet, it receives a response (an HTTP 302 response) that tells it that the document it requested can actually be found at /anotherURL. The client uses the URL it gets and makes a new request to /anotherURL.

    The redirect URL doesn't have to be on the same server as the original URL. If the redirect URL (/anotherURL) points to another servlet, new request and response objects will be created to handle the new request.

    Suppose our redirect servlet is now changed to do a forward instead of a redirect:

    protectedvoid doGet(HttpServletRequest request, HttpServletResponse response)
    {
      ServletContext context = getServletContext();
      RequestDispatcher dispatcher = context.getRequestDispatcher("/anotherURL");
      dispatcher.forward(request, response);
    }


    This modified servlet is accessible through the URL /forwardServlet.

    When the client makes a request to our forwarding servlet this time, it no longer receives the redirect response. The dispatcher.forward line causes the servlet container to run the servlet associated with the url /anotherURL directly. The client will receive the result of /anotherURL, even though they requested /forwardServlet.

    A few more notes:

    * Redirect is a two step process. The web server tells the browser to request a second URL.
    * If the user reloads, the second URL will be reloaded (/anotherURL instead of /redirectServlet).
    * Redirect is always slower than a forward because it requires a second client request.
    * Attributes placed in the request scope of the redirecting servlet are not available in the request scope of the second rrequest.

    * Forwards are performed internally to the web server.
    * The browser is completely unaware that the forward took place - the original URL (/forwardServlet) remains in the address bar.
    * If the user does a reload, the browser will repeat the original request with the original URL (/forwardServlet).

    from: http://forum.java.sun.com/thread.jspa?threadID=627801&messageID=3597659

    posted on 2006-11-03 02:19 weidagang2046 閱讀(519) 評論(0)  編輯  收藏 所屬分類: Java

    主站蜘蛛池模板: 一级毛片在播放免费| 亚洲成a人无码亚洲成av无码| caoporm超免费公开视频| 免费少妇a级毛片| 久久久久亚洲国产AV麻豆| 精品久久久久久久免费加勒比| 91亚洲国产成人久久精品 | 亚洲精品国产电影| 免费国产污网站在线观看不要卡| 国产精品二区三区免费播放心 | 亚洲AV永久无码精品水牛影视| 大地资源网高清在线观看免费| 久久久久亚洲精品影视| 青青视频观看免费99| 亚洲天堂免费在线| 国产美女做a免费视频软件| 男女猛烈激情xx00免费视频| 久久久久国产成人精品亚洲午夜| 巨胸喷奶水www永久免费| 亚洲无线电影官网| 国国内清清草原免费视频99| 亚洲精品av无码喷奶水糖心| 亚洲 小说区 图片区 都市| a级毛片黄免费a级毛片| 亚洲美女视频网站| 日韩一区二区在线免费观看 | 东北美女野外bbwbbw免费 | 亚洲无线电影官网| 卡一卡二卡三在线入口免费| 人妻仑乱A级毛片免费看| 亚洲精品私拍国产福利在线| 成人人观看的免费毛片| 一级一看免费完整版毛片| 亚洲视频日韩视频| 免费网站看v片在线香蕉| 一级毛片a免费播放王色| 亚洲第一成年人网站| 国产色婷婷精品免费视频| a级毛片免费播放| 亚洲熟伦熟女专区hd高清| 伊人婷婷综合缴情亚洲五月|