私はサーブレットに関する本を読んでレビューしていますが、セッション ID をいつ追加するかを自動的に決定すると書かれています。ウェブ上で相反する声明を読みました。Cookie がブロックされたときにセッション ID を URL に自動的に追加する範囲と、これには sendRedirect() の使用が含まれます。最新版を参考にしています。Oracle.com で The JAVA Docs を確認しましたが、最近十分に更新されているかどうかはわかりません。
ありがとう :-)
私はサーブレットに関する本を読んでレビューしていますが、セッション ID をいつ追加するかを自動的に決定すると書かれています。ウェブ上で相反する声明を読みました。Cookie がブロックされたときにセッション ID を URL に自動的に追加する範囲と、これには sendRedirect() の使用が含まれます。最新版を参考にしています。Oracle.com で The JAVA Docs を確認しましたが、最近十分に更新されているかどうかはわかりません。
ありがとう :-)
いいえ、コンテナーには、出力ストリームに書き込むテンプレート テキストまたは文字列内のリンクを検出するインテリジェンスがありません。
Ex の場合、次のサンプル コードを使用します。
servletoutputStream.write("<form method=\"post\" action=\"/submit.jsp\");
上記のコードでHttpServletResponse.encodeURL("/submit.jsp")
は、投稿アクション URL にセッション ID を含める必要があります。
同様に、APIドキュメントに HttpServletResponse.encodeRedirectURL()
は次のように書かれています
java.lang.String encodeRedirectURL(java.lang.String url)
Encodes the specified URL for use in the sendRedirect method or, if encoding
is not needed, returns the URL unchanged. The implementation of this method
includes the logic to determine whether the session ID needs to be encoded in
the URL.Because the rules for making this determination can differ from those
used to decide whether to encode a normal link, this method is separated from
the encodeURL method.
All URLs sent to the HttpServletResponse.sendRedirect method should be run
through this method. Otherwise, URL rewriting cannot be used with browsers
which do not support cookies.
参考文献: