ピーターは正しいです。はPageContext
、ページの処理範囲に対してプロビジョニングされています。コンシューマーは、このスコープ外でこれらのインスタンスへの参照を保持しないでください。これは、現在のスレッドの外部でインスタンスにアクセスできないことを暗黙的に意味します。
JSP 2.2仕様のJSP処理コードの例:
public class foo implements Servlet {
// ...
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
JspFactory factory = JspFactory.getDefaultFactory();
PageContext pageContext = factory.getPageContext(
this,
request,
response,
null, // errorPageURL
false, // needsSession
JspWriter.DEFAULT_BUFFER,
true // autoFlush
);
// initialize implicit variables for scripting env ...
HttpSession session = pageContext.getSession();
JspWriter out = pageContext.getOut();
Object page = this;
try {
// body of translated JSP here ...
} catch (Exception e) {
out.clear();
pageContext.handlePageException(e);
} finally {
out.close();
factory.releasePageContext(pageContext);
}
}
PageContext
インスタンスが(プールまたはインスタンスの作成から)プロビジョニングされる方法は、コンテナーの実装の詳細です。