• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Http Session and PortletSession?

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whats the difference between Http Session and PortletSession? How are they related or how they are different and what is the scope of each? Can someone please guide me to some documentation or please explain me.

Thanks in advance
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best document to explain this is the JSR SPec. WHich we have a link at the top of this forum.

Mark
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

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.

Thanks
Dhananjay
 
Romi Dave
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This has created few more doubts in my mind. Can there be multiple PortletSessions for a HttpSession? In my application on the home page I have different portlets each can be accessed by the link so when is the particular portletsession created?

Thanks
 
Dhananjay Inamdar
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Romi,

You are correct....every Portlet has it's own PortletSession.
As Portlet is a self-containted, reusable web-application, and has it's own saperate PortletSession. This session is not sharable across 2 portlets on the same page.

Thanks
Dhananjay
 
Romi Dave
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Well now to ask you more, In my application I have a home page which is a portlet and it has a common template which has links to the other portlets. Now when I start the application I first get to see Home page and a Session is created. So is this session Like a Parent portlet and any other portlet that i access are the child of it or within the main portlet? When i try to get the session id i always get the same session id irrespective of which portlet i am in. Can you please explain.

Thanks,
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, on this topic, you've got to realize that the PortletSession is just piggybacking on the HttpSession. Sure, one Portlet can't see another Portlet's PortletSession data, but if you go into a JSP, grab the HttpSession from the page, not the PortletSession, but the HttpSession (you can do it, after all, it is a JSP page), you'll find all of the various PorletSession data objects stuffed inside the HttpSession...The only difference is the Portal has given all teh PortletSession data objects crazy namespace names so that one portlet can't see another portlets session data. Do you think the application server is creating new database rows for every PortletSession though? Not a chance...That'd be way too wasteful.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI

I am trying to get the session value from oracle portlet to servlet and I am getting null value

I am able to set the session value and get it back in same jsp but it's not reachable from servlet

I already went thur the oracle doc and did what it says but still it's not working for me

can someone please help me out.



thanks
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...

Hope this makes something clear...
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The PortletSession object extends from HttpSession and serves much the same
purpose.



The portlet session does NOT extend the HttpSession in all Portlet containers. The JSR specs do not require the PortletSession to be extended from HttpSession.

Some containers (WebSphere) implemented it this way, but this need not be true for others (Jboss)
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic