Portlet and HTTP Sessions

As noted in the PLT.18.3 section of the Portlet 2.0 spec, the PortletSession interface defines two scopes for storing objects, APPLICATION_SCOPE and PORTLET_SCOPE.

The default scope is PORTLET_SCOPE, even though, as noted in the PLT.10.4.3 section, the default for the session variable of included / forwarded servlets or JSPs is that it maps to the portlet session with application scope.

Even though you can change it to PORTLET_SCOPE, as noted in the same section, you may want to change your code:

Portlet

final PortletSession ses = req.getPortletSession();

ses.setAttribute("blogName", "Simples Assim", PortletSession.APPLICATION_SCOPE);

JSP

${sessionScope.blogName}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s