[EMAIL PROTECTED] www.onehippo.com
San Francisco - Hippo USA Inc. 101 H Street, Suite Q Petaluma CA
94952-3329 +1 (877) 41-HIPPO
Amsterdam - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466
On Oct 15, 2008, at 1:54 PM, Michael Binette wrote:
I need to create a portlet that is going to go on the same page as
the "User
Browser" and "User Detail Information" portlets. It needs to display
information based on the user selected. Reviewing the code for
these, the
"User Detail Information" portlet uses:
String userName = (String)PortletMessaging.receive(request,
SecurityResources.TOPIC_USERS,
SecurityResources.MESSAGE_SELECTED);
to retrieve the username selected in the "User Browser" portlet.
I am trying to make the same call in my own portlet that is in a
different
web app. Looking at the code for PortletMessaging, all it is really
doing
is getting the attribute "users:selected" from the PortletSession,
APPLICATION_SCOPE. So I would expect it to work in my portlet as
well. But
when I look at the session during my doView function it shows things
like
"cps:UserManager" but not the "users:selected" value.
The "User Detail Information" porttlet uses PortletMessaging.receive
and not
PortletMessage.consume so I would expect the value to still be in
the users
session. My Tomcat server.xml already has emptyServerPath="true" so
I'm not
sure why this wouldn't work. Any ideas?
Looking at the Tomcat HowTo Wiki, it says:
http://wiki.apache.org/tomcat/HowTo#head-676687dc9e14f16a2dbe0e207447803a757198ac
Q. How do I share sessions across web apps?
A. You cannot share sessions directly across web apps, as that would
be a violation of the Servlet Specification. There are workarounds,
including using a singleton class loaded from the common classloader
repository to hold shared information, or putting some of this shared
information in a database or another data store. Some of these
approaches have been discussed on the [WWW] tomcat-user mailing list,
whose archives you should search for more information.
Sharing sessions across containers for clustering or replication
purposes is a different matter altogether.
That said, some solutions seem to be available:
> Is there a way to share sessions across webapps running in the same
> container?
Yes, I do this for a set of apps which I wrote recently.
You need to make sure each of the apps which need access to the
cross-context session are defined like this in server.xml:
<Context path="/mycontext" docBase="mydocbase" debug="0"
reloadable="true"
crossContext="true">
...
</Context>
crossContext="true" is the important bit.
But then it goes on to explain certain constraints, read on:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg116223.html
The 2.0 Portlet Events (JSR-286) solves your use case (and ours) when
ready in Jetspeed