學習筆記

          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 閱讀(254) 評論(0)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 甘肃省| 彭泽县| 乡城县| 凉城县| 花垣县| 四平市| 黎川县| 瑞丽市| 商洛市| 阿瓦提县| 嘉兴市| 泸溪县| 邛崃市| 中西区| 应用必备| 乌兰察布市| 兴城市| 郴州市| 信丰县| 宿迁市| 门头沟区| 祥云县| 长海县| 连南| 沙洋县| 阿图什市| 吉首市| 辽宁省| 佛冈县| 诸暨市| 常德市| 布尔津县| 茌平县| 宜州市| 时尚| 行唐县| 卢湾区| 鹤岗市| 明溪县| 瓦房店市| 姜堰市|