How to access a session attribute

I'm in the process of converting a regular web application to a portlet. I expected some issues allong the way, but access variables was not one of them. I am posting her because I can see the object in the sessionScope. It just doesn't seem to have a name I can reference.

public Object getKey(PortletRequest request)

{

request.getPortletSession().setAttribute("KEY", object);

}

I have a debug.jsp that list session varibles done like so:

<tr>

<th colspan="2" style="background:aqua"><b>session</b></th>

</tr>

<c:forEach items="${sessionScope}" var="itm">

<tr>

<td><c:out value="${itm.key}"/></td>

<td><c:out value="${itm.value}"/></td>

</tr>

</c:forEach>

Which prints out this: (I've removed some output....)

session

com.liferay.util.servlet.SessionParameters gnu.trove.THashMap@b867500b

COMPANY_ID liferay.com

PORTLET_RENDER_PARAMETERS gnu.trove.THashMap@1a0725a3

LAST_PATH com.liferay.util.ObjectValuePair@fd8b9

javax.portlet.p.portletname-web-1.0.0_WAR_dispatch_portlet?KEY com.liferay.portletname.admin.util.Object@1967db7

IMAGE_PATH /image

USER_ID liferay.com.1

USER_PASSWORD ****

CTX_PATH /c

SHARED_SESSION_ID YEM3OO9KF87J

CACHE_PORTLET_RESPONSES gnu.trove.THashMap@0

So far so good, I can see the object I want in the session, but how do I reference it? The object I want is this one:

javax.portlet.p.portletname-web-1.0.0_WAR_dispatch_portlet?KEY com.liferay.portletname.admin.util.Object@1967db7

Any help would be much appriciated.

[1729 byte] By [jborna] at [2007-10-2 10:56:47]
# 1

I figured out a work around:

request.getPortletSession().setAttribute("KEY", object, 0);

Now "KEY" is seen in my portlet via <c:when test="${KEY.userView != null}">

After a little more digging it seems that my session attribute is being wrapped with the following call: btw (I passed in 0 for scope and PortletSession.PORTLET_SCOPE = 1) so the if really is if(0 == 1) )

if (scope == PortletSession.PORTLET_SCOPE) {

_ses.setAttribute(_getPortletScopeName(name), value);

}

else {

_ses.setAttribute(name, value);

}

So if I go back and remove the 0 from the following set:

request.getPortletSession().setAttribute(

Constants.KEY,

container);

Then I need to know how to run _getPortletScopeName(name) on an attribute key name in a JSP and better yet under jstl

Thanks for the info

jborna at 2007-7-13 3:22:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...