學習筆記

          Simple is beautiful.

          導航

          <2007年9月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          統計

          公告

          ...

          常用鏈接

          留言簿(1)

          隨筆分類(2)

          隨筆檔案(56)

          Weblog

          搜索

          最新評論

          評論排行榜

          Coding Guidelines for URL Rewriting

          There are some general guidelines for how your code should handle URLs in order to support URL rewriting.

          • Avoid writing a URL straight to the output stream, as shown here:
            out.println("<a href=\"/myshop/catalog.jsp\">catalog</a>");

            Instead, use the HttpServletResponse.encodeURL() method, for example:

            out.println("<a href=\""
            + response.encodeURL("myshop/catalog.jsp")
            + "\">catalog</a>");

            Calling the encodeURL() method determines if the URL needs to be rewritten, and if so, it rewrites it by including the session ID in the URL. The session ID is appended to the URL and begins with a semicolon.

          • In addition to URLs that are returned as a response to WebLogic Server, also encode URLs that send redirects. For example:
            if (session.isNew())
              response.sendRedirect (response.encodeRedirectUrl(welcomeURL));

            WebLogic Server uses URL rewriting when a session is new, even if the browser does accept cookies, because the server cannot tell whether a browser accepts cookies in the first visit of a session.

          • Your servlet can determine whether a given session ID was received from a cookie by checking the Boolean returned from the HttpServletRequest.isRequestedSessionIdFromCookie() method. Your application may respond appropriately, or simply rely on URL rewriting by WebLogic Server.

          posted on 2007-09-01 11:48 Ecko 閱讀(251) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 台东市| 通河县| 扶绥县| 昂仁县| 天门市| 松滋市| 城口县| 海阳市| 舒兰市| 汤原县| 长海县| 留坝县| 天等县| 安图县| 东方市| 临清市| 景谷| 宿州市| 深圳市| 高平市| 赤壁市| 女性| 鲁山县| 崇州市| 大理市| 岐山县| 巴林右旗| 湖南省| 平遥县| 富锦市| 漳平市| 来凤县| 内黄县| 岳西县| 额济纳旗| 北京市| 盐亭县| 洪江市| 南昌县| 安国市| 涿州市|