「3.2 基本的な属性スコープ(request, session, context)」の版間の差分
ナビゲーションに移動
検索に移動
(ページの作成:「==サーブレットコードで属性を追加、取得、削除する。ある状況において、ある属性に適したスコープを識別し、それぞれのス…」) |
|||
52行目: | 52行目: | ||
---- | ---- | ||
{{amazon|1932394389}} | {{amazon|1932394389}} | ||
− | [http://www.amazon.co.jp/dp/1932394389?tag=typea09-22&link_code=as3&creativeASIN=1932394389&creative=3999&camp=767 SCWCD Exam Study Kit: Java Web Component Developer Certification (ペーパーバック)] | + | [[http://www.amazon.co.jp/dp/1932394389?tag=typea09-22&link_code=as3&creativeASIN=1932394389&creative=3999&camp=767 SCWCD Exam Study Kit: Java Web Component Developer Certification (ペーパーバック)]] |
2020年2月15日 (土) 08:00時点における版
サーブレットコードで属性を追加、取得、削除する。ある状況において、ある属性に適したスコープを識別し、それぞれのスコープに関連したマルチスレッドにおける問題性を識別する
データの共有
スコープ | コンテナクラス | 内容 |
---|---|---|
request | ServletRequest | リクエスト完了まで |
session | HttpSession | クライアントが無効になるまで |
context | ServletContext | Webアプリケーションが終了するまで |
共通の属性操作メソッド
メソッド名 | 内容 |
---|---|
getAttribute(String) | 属性の取得 |
getAttributeNames() | 属性のキーセットの取得 |
setAttribute(String, Object) | 属性のキーと値のセット |
removeAttribute(String) | 属性の削除 |
request.setAttribute(key, val); request.removeAttribute(key);
HttpSession session = request.getSession(); session.setAttribute(key, val); session.removeAttribute(key);
ServletContext context = getServletContext(); context.setAttribute(key, val); context.removeAttribute(key);
[SCWCD Exam Study Kit: Java Web Component Developer Certification (ペーパーバック)]
© 2006 矢木浩人