The NoteBook of EricKong

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            611 Posts :: 1 Stories :: 190 Comments :: 0 Trackbacks
          When the user initially accesses a portlet, a PortletSession is created. The portlet
          session stores transient data associated with an individual use of the portlet.

          The PortletSession object extends from HttpSession and serves much the same
          purpose. The PortletSession is intended to represent an ongoing conversation between the client and the portlet. To this end, the PortletSession can be used to store information needed between requests. The PortletSession is intended to store data between requests, not between portlets. As such, data stored in the session by one portlet is not accessible by another. The PortletSession is retrieved from the request object.


          Well both Portlets and Servlets are loaded using the same classloader.So it's a plain fact that session can be made available in both the contexts.

          As far as the portlets are concerned,
          The PortletSession is namespaced :
          1) PORTLET_SCOPE : Only available to the particular portlet.
          2) APPLICATION_SCOPE: Available to all Portlets and also available in Servlets/JSP etc

          So, if you really want to share sessions among Servlets and Portlets...
          1) Define the scope of the session attributes as APPLICATION_SCOPE in Portlets....
          2) Access the session attributes defined or set in servlets by specifying APPLICATION_SCOPE.. else you will get null.

          As far as retrieving the PortletSession from HttpRequest is concerned.. You can get them via the APIs available..
          For JSR168 Struts Portlets we have WpsStrutsUtil package that will return you the PortletSession...

          posted on 2011-11-09 12:02 Eric_jiang 閱讀(488) 評論(0)  編輯  收藏 所屬分類: WebShpere
          主站蜘蛛池模板: 平顶山市| 东辽县| 同德县| 遂昌县| 平远县| 临朐县| 昌宁县| 乡宁县| 罗源县| 永康市| 正镶白旗| 丽江市| 南通市| 厦门市| 集贤县| 苏州市| 正镶白旗| 同心县| 云浮市| 英山县| 武隆县| 大丰市| 苏尼特左旗| 定陶县| 涟水县| 喀什市| 灌阳县| 三亚市| 宁武县| 洪雅县| 包头市| 谷城县| 交城县| 临海市| 荥经县| 姚安县| 拉萨市| 聂荣县| 宁陕县| 教育| 沙河市|