You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jany Jose <ja...@gmail.com> on 2011/08/03 08:23:50 UTC
Sharing session between different webapps under same tomcat
Hi,
We are using tomcat 6.0.26. For one use case we want to re-use the session
objects created in one web application in another web application which are
running under the same tomcat. Please let me know is it supported and if yes
how to achieve that.
Thanks
Jany
Re: Sharing session between different webapps under same tomcat
Posted by Mark Thomas <ma...@apache.org>.
On 03/08/2011 07:23, Jany Jose wrote:
> Hi,
>
> We are using tomcat 6.0.26. For one use case we want to re-use the session
> objects created in one web application in another web application which are
> running under the same tomcat. Please let me know is it supported and if yes
> how to achieve that.
It is not supported.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Sharing session between different webapps under same tomcat
Posted by Ron McNulty <rm...@clear.net.nz>.
Hi Chema
I take your point. But this is a problem solved by JSR168/286 portal
implementations. Perhaps you could use a portal for your purposes? Otherwise
I would suggest taking a look at Apache Jetspeed or Liferay source code to
see how they implement cross-war session sharing. Both portals can be hosted
by multiple J2EE containers, so their solution must be independent of
Tomcat.
Regards
Ron
----- Original Message -----
From: "Chema" <de...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Saturday, August 06, 2011 10:54 PM
Subject: Re: Sharing session between different webapps under same tomcat
> Hi Ron:
>
>
>> My understanding is that once these options are confgured, the SAME
>> session
>> data is stored across contexts separately for each user.
>
> Thanks for you answer, but in the last seccion of that webpage
> (Session-aware cross context data sharing), explains that:
>
> - he's sharing data using ServletContext. Its scope is the application
> scope, not the session scope.
> - to make it session-aware , he creates a hashmap in application scope
> , indexing by JSESSIONID
>
> So, it's a trick: use the session1's ServletContext as a global store
> and access to it from session2, cause crossContext="true"
> Works but it's a trick because it's not managed by Tomcat
>
>> There is no need to
>> do anything special - the session will be explicitly invalidated when the
>> user logs out, otherwise when the session timeout is exceeded.
>
> If I dont free resources from this hashmap manually when a session is
> invalidated, Tomcat doesn't ( except when restarting )
> That can be a problem if store big objects, like user information
>
>
> Regards
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Sharing session between different webapps under same tomcat
Posted by Chema <de...@gmail.com>.
Hi Ron:
> My understanding is that once these options are confgured, the SAME session
> data is stored across contexts separately for each user.
Thanks for you answer, but in the last seccion of that webpage
(Session-aware cross context data sharing), explains that:
- he's sharing data using ServletContext. Its scope is the application
scope, not the session scope.
- to make it session-aware , he creates a hashmap in application scope
, indexing by JSESSIONID
So, it's a trick: use the session1's ServletContext as a global store
and access to it from session2, cause crossContext="true"
Works but it's a trick because it's not managed by Tomcat
> There is no need to
> do anything special - the session will be explicitly invalidated when the
> user logs out, otherwise when the session timeout is exceeded.
If I dont free resources from this hashmap manually when a session is
invalidated, Tomcat doesn't ( except when restarting )
That can be a problem if store big objects, like user information
Regards
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Sharing session between different webapps under same tomcat
Posted by Ron McNulty <rm...@clear.net.nz>.
Hi Chema
My understanding is that once these options are confgured, the SAME session
data is stored across contexts separately for each user. There is no need to
do anything special - the session will be explicitly invalidated when the
user logs out, otherwise when the session timeout is exceeded.
I'm not sure why you are worried that session data for "all users which were
logged" is a problem. You simply set the appropriate flags and forget
session data. Both Jetspeed and (I think) Liferay portal servers rely on
this provided behaviour.
Regards
Ron
----- Original Message -----
From: "Chema" <de...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Thursday, August 04, 2011 10:26 PM
Subject: Re: Sharing session between different webapps under same tomcat
> OK, I got it
>
> Use context scope to store a HashMap object indexing by JSESSIONID
>
> I guess , this way you have to free manually all per-user session data
> from the context when user session is finished ( by example, closing
> browser).
> Or your context scope datastore could be full of information of all
> users which were logged , right ?
>
>
>
> 2011/8/4 Ron McNulty <rm...@clear.net.nz>:
>> Sorry, I think you are missing something :) The session is per user
>> across
>> multiple contexts. Portlet apps are typically compiled into separate .war
>> files, but can share a single session object at runtime.
>>
>> Regards
>>
>> Ron
>>
>> ----- Original Message ----- From: "Chema" <de...@gmail.com>
>> To: "Tomcat Users List" <us...@tomcat.apache.org>
>> Sent: Thursday, August 04, 2011 6:39 PM
>> Subject: Re: Sharing session between different webapps under same tomcat
>>
>>
>>>> I think it is possible to share sessions across contexts. Portal
>>>> applications need to do this. Try
>>>>
>>>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>>>>
>>>
>>> But this solution shares information between contexts , not creates an
>>> unique shared session per user (session data)
>>>
>>> am i wrong ?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Sharing session between different webapps under same tomcat
Posted by Chema <de...@gmail.com>.
OK, I got it
Use context scope to store a HashMap object indexing by JSESSIONID
I guess , this way you have to free manually all per-user session data
from the context when user session is finished ( by example, closing
browser).
Or your context scope datastore could be full of information of all
users which were logged , right ?
2011/8/4 Ron McNulty <rm...@clear.net.nz>:
> Sorry, I think you are missing something :) The session is per user across
> multiple contexts. Portlet apps are typically compiled into separate .war
> files, but can share a single session object at runtime.
>
> Regards
>
> Ron
>
> ----- Original Message ----- From: "Chema" <de...@gmail.com>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Thursday, August 04, 2011 6:39 PM
> Subject: Re: Sharing session between different webapps under same tomcat
>
>
>>> I think it is possible to share sessions across contexts. Portal
>>> applications need to do this. Try
>>>
>>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>>>
>>
>> But this solution shares information between contexts , not creates an
>> unique shared session per user (session data)
>>
>> am i wrong ?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Sharing session between different webapps under same tomcat
Posted by Ron McNulty <rm...@clear.net.nz>.
Sorry, I think you are missing something :) The session is per user across
multiple contexts. Portlet apps are typically compiled into separate .war
files, but can share a single session object at runtime.
Regards
Ron
----- Original Message -----
From: "Chema" <de...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Thursday, August 04, 2011 6:39 PM
Subject: Re: Sharing session between different webapps under same tomcat
>> I think it is possible to share sessions across contexts. Portal
>> applications need to do this. Try
>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>>
>
> But this solution shares information between contexts , not creates an
> unique shared session per user (session data)
>
> am i wrong ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Sharing session between different webapps under same tomcat
Posted by Chema <de...@gmail.com>.
> I think it is possible to share sessions across contexts. Portal
> applications need to do this. Try
> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>
But this solution shares information between contexts , not creates an
unique shared session per user (session data)
am i wrong ?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Sharing session between different webapps under same tomcat
Posted by Ron McNulty <rm...@clear.net.nz>.
Hi Jany
I think it is possible to share sessions across contexts. Portal
applications need to do this. Try
http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
Regards
Ron
----- Original Message -----
From: "Jany Jose" <ja...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Wednesday, August 03, 2011 6:23 PM
Subject: Sharing session between different webapps under same tomcat
> Hi,
>
> We are using tomcat 6.0.26. For one use case we want to re-use the session
> objects created in one web application in another web application which
> are
> running under the same tomcat. Please let me know is it supported and if
> yes
> how to achieve that.
>
> Thanks
> Jany
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org