You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dominique Jocal <dj...@octo.com> on 2007/04/08 23:09:09 UTC

sharing same session across multiple webapp

Hi,

we'd like to make modular web development, not with merging in 1 
deployable webapp separate web sources, but with making run 2 webapps 
sharing the same user's session.

We all know JEE standard does not specify such thing for the moment, but 
servers start to enable it a proprietary way (see weblogic 9 for instance)

Is there a way in Tomcat to share the same user's session across 
multiple webapps, for this purpose of modular development ?

Thank to any suggestion,

Dominique.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: sharing same session across multiple webapp

Posted by Rashmi Rubdi <ra...@gmail.com>.
I think it is possible, if you set the crossContext="true" , in both
application's Context.

Details on crossContext attribute is here:
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

-Rashmi

On 4/8/07, Dominique Jocal <dj...@octo.com> wrote:
>
> Is there a way in Tomcat to share the same user's session across
> multiple webapps ?
>
> Thank to any suggestion,
>
> Dominique.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: sharing same session across multiple webapp

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
OK I understand....
I think you looking for an application server or maybe a shared resource....

Have a look at yet another approach.... JNDI Resources... Resource Factories
http://tomcat.apache.org/tomcat-4.1-doc/jndi-resources-howto.html
You may be able to bring the unique apps in thru a custom resource 
factory....

But I really think what you looking at is an application server... and there 
are 2 issues, a huge Super-Can learning  curve and... they become 
inseparable, that is the application once ported to the Super-Can, depends 
on the super can, and is no longer POJO... It has to live in Spring or 
Jboss...maybe thats ok.

I really dont like the idea of seperate web apps with a shared user 
session... I think you will break or make any future clustering hellish 
complicated.
Rather, join the applications via an application server... in a servlet... 
and use the servlet to display the required JSP pages.

Then if this servlet gets busy.... do clustering of that Web-App say behind 
apache, and at least the session management will be something a load 
balancer understands and can deal with... I'm worried that if you mess 
around with sessions yourself toooo much, next thing you will be asking is 
how to write a cluster controller that understands how your users move 
between different web-apps.... mission impossible.

Ok... so if you go for joining applications in a web servlet you need an 
application server.

Now maybe I can help you... but you need to test my applications carefully 
before commiting to anything.
I dont like the way applications servers force your code to live inside the 
application server.... or another way of putting it, is I dont like the fact 
that its impossible to test your code as POJO outside of the application 
server... so I made a POJO container... maybe it will help you.

Briefly... you write a normal POJO application.... you drop it into my 
application server (HARBOR) and then you can run the classes in the server 
or remotely.

If I want to run a class on another machine... code looks like this
        Class msgTest = 
vessel.getRemoteClass("harbor.classContainer.MsgTest");//load a class from 
the harbor
        I_MsgTest i_MsgTest = (I_MsgTest)vessel.newInst(msgTest);//can have 
many instances of a single class (its just like new)

If I want to run the class IN the server...... code looks like this

        I_serialContainer i_serialContainer = 
(I_serialContainer)vessel.loadRemoteClassInst
                 (I_serialContainer.class,"harbor.classContainer.serialContainer",true);//load 
a class instance ON the harbor

I tried to keep it simple....
And yes you can share classes.... and the applications can be on different 
machines to the servlet.

HARBOR itself is just a Servlet... so Tomcat is all you need

Ok just wanted to give you an idea.... you can get Harbor at 
http://coolese.100free.com

Another possibility is Resin... its a servlet with an EJB container... so it 
may do what you need. I based Harbor on one of their protocols... hessian.

So... what I would do is .... join applications in a servlet... which calls 
jsp to display output... no logic in the jsp other than display.
I would take the seperate applications... dump them into Harbor and call 
them as needed in the servlet.
If it gets big.... use normal clustering.

You could do the same thing... but port your applications to JBoss... so you 
dont depend on my technology... I program for fun, and I might take up 
golf...ha ha.

In my solution.... its one WAR file and the Jar file of each app.
In Jboss it would probably be an EAR file for each app and a WAR file...

Then you have what you want.... a container for your web app, and a 
container for your unique applications.

Or you could do it one of the other million ways discussed.... no one can 
ever blame java for not having enough frameworks ;)

It all gets very confusing, but at the base of all these technologies... its 
just a classloader, for example JNDI Resources at its core is just exposing 
a common classloader. HARBOR my app is also just class loaders, with the 
ability to call methods remotely, JBOSS just another amalgamation of 
classloaders, and so is tomcat... simplistic view, but thats what I think 
you and many others are really asking... find me a cool way to load up 
classes and run them... and every idea is another framework ;)

Good luck

----- Original Message ----- 
From: "Dominique Jocal" <dj...@octo.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Monday, April 09, 2007 6:17 PM
Subject: Re: sharing same session across multiple webapp


> Thank you to you both, I understand now at what think at when you indicate 
> using a "shared context"; it can help to exchange data between 2 webapps, 
> and so, after some implementation, to have this session sharing. It's 
> however requiring some implementation, to "map" the 2 sessions and to 
> manage all other stuff (session timeout, etc). As you Johnny, can be very 
> messy.
>
> To answert to you again, Johnny, my business need is to separate the 
> functionalities of a real UNIQUE application for a functional point of 
> view in 2 or  + development artefacts, in order to facilitate modularity. 
> Let me precise: development modularity; we're ok for having 1 unique 
> application at run time; because basically, this is it; all modules "work 
> together".
> Jars are ok for the java code, we're missing another type of artefact for 
> the presentation code (jsp). A possible target is to have multiple 
> webapps, and to share a user's session across all of them. But another 
> possible solution is to "merge" all the development artefacts in 1 final 
> JEE webapp at build-time; because basically, separation is not required at 
> run time but at development time only.
>
> So to say it simpler, the need is to be able to "package" JSP in different 
> 'artefacts' (wars ? jars ?) and  however  to allow them to work with the 
> same user information in the HTTP session.
> Do you other solutions than 1) 2 webapps sharing session 2) merging 
> webapps?
>
> I'll give a look to Spring facilities if it covers this kind of thing.
>
> see you - Dominique.
>
> Johnny Kewl a écrit :
>> Always a big question... search the web and you find many different 
>> approaches
>>
>> Here is an article how to do it using servlet contexts...
>> http://www.fwd.at/tomcat/sharing-session-data-howto.html
>>
>> But maybe clustering is what you looking for
>> Have a look at tomcat clustering and session replication.
>>
>> Other popular approach is Apache JK_mod clustering and sticky 
>> sessions.... my favorite
>>
>> And then maybe what you really looking for is an application server...
>> Spring framework or something like Jboss.... something that lets you 
>> share a bean.
>> Granted... they huge fat frameworks if thats all you want to do..
>>
>> I think you need to qualify the question a little...
>> Are you just trying to share a session in a cluster... ie identicle 
>> webapps -> Clustering
>>
>> Or are you trying to share a bean across different webapps -> App server
>>
>> Or are you trying to share a shared status across different webapps -> 
>> App server singleton
>>
>> Servlet contexts... can kinda do all of the above... but its kludgy... 
>> think it can get very messy.
>>
>> Good luck
>>
>>
>> ----- Original Message ----- From: "Dominique
>> To: <us...@tomcat.apache.org>
>> Sent: Sunday, April 08, 2007 11:09 PM
>> Subject: sharing same session across multiple webapp
>>
>>
>>> Hi,
>>>
>>> we'd like to make modular web development, not with merging in 1 
>>> deployable webapp separate web sources, but with making run 2 webapps 
>>> sharing the same user's session.
>>>
>>> We all know JEE standard does not specify such thing for the moment, but 
>>> servers start to enable it a proprietary way (see weblogic 9 for 
>>> instance)
>>>
>>> Is there a way in Tomcat to share the same user's session across 
>>> multiple webapps, for this purpose of modular development ?
>>>
>>> Thank to any suggestion,
>>>
>>> Dominique.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: sharing same session across multiple webapp

Posted by Dominique Jocal <dj...@octo.com>.
Thank you to you both, I understand now at what think at when you 
indicate using a "shared context"; it can help to exchange data between 
2 webapps, and so, after some implementation, to have this session 
sharing. It's however requiring some implementation, to "map" the 2 
sessions and to manage all other stuff (session timeout, etc). As you 
Johnny, can be very messy.

To answert to you again, Johnny, my business need is to separate the 
functionalities of a real UNIQUE application for a functional point of 
view in 2 or  + development artefacts, in order to facilitate 
modularity. Let me precise: development modularity; we're ok for having 
1 unique application at run time; because basically, this is it; all 
modules "work together".
Jars are ok for the java code, we're missing another type of artefact 
for the presentation code (jsp). A possible target is to have multiple 
webapps, and to share a user's session across all of them. But another 
possible solution is to "merge" all the development artefacts in 1 final 
JEE webapp at build-time; because basically, separation is not required 
at run time but at development time only.

So to say it simpler, the need is to be able to "package" JSP in 
different 'artefacts' (wars ? jars ?) and  however  to allow them to 
work with the same user information in the HTTP session.
Do you other solutions than 1) 2 webapps sharing session 2) merging webapps?

I'll give a look to Spring facilities if it covers this kind of thing.

see you - Dominique.

Johnny Kewl a écrit :
> Always a big question... search the web and you find many different 
> approaches
>
> Here is an article how to do it using servlet contexts...
> http://www.fwd.at/tomcat/sharing-session-data-howto.html
>
> But maybe clustering is what you looking for
> Have a look at tomcat clustering and session replication.
>
> Other popular approach is Apache JK_mod clustering and sticky 
> sessions.... my favorite
>
> And then maybe what you really looking for is an application server...
> Spring framework or something like Jboss.... something that lets you 
> share a bean.
> Granted... they huge fat frameworks if thats all you want to do..
>
> I think you need to qualify the question a little...
> Are you just trying to share a session in a cluster... ie identicle 
> webapps -> Clustering
>
> Or are you trying to share a bean across different webapps -> App server
>
> Or are you trying to share a shared status across different webapps -> 
> App server singleton
>
> Servlet contexts... can kinda do all of the above... but its kludgy... 
> think it can get very messy.
>
> Good luck
>
>
> ----- Original Message ----- From: "Dominique
> To: <us...@tomcat.apache.org>
> Sent: Sunday, April 08, 2007 11:09 PM
> Subject: sharing same session across multiple webapp
>
>
>> Hi,
>>
>> we'd like to make modular web development, not with merging in 1 
>> deployable webapp separate web sources, but with making run 2 webapps 
>> sharing the same user's session.
>>
>> We all know JEE standard does not specify such thing for the moment, 
>> but servers start to enable it a proprietary way (see weblogic 9 for 
>> instance)
>>
>> Is there a way in Tomcat to share the same user's session across 
>> multiple webapps, for this purpose of modular development ?
>>
>> Thank to any suggestion,
>>
>> Dominique.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: sharing same session across multiple webapp

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
Always a big question... search the web and you find many different 
approaches

Here is an article how to do it using servlet contexts...
http://www.fwd.at/tomcat/sharing-session-data-howto.html

But maybe clustering is what you looking for
Have a look at tomcat clustering and session replication.

Other popular approach is Apache JK_mod clustering and sticky sessions.... 
my favorite

And then maybe what you really looking for is an application server...
Spring framework or something like Jboss.... something that lets you share a 
bean.
Granted... they huge fat frameworks if thats all you want to do..

I think you need to qualify the question a little...
Are you just trying to share a session in a cluster... ie identicle 
webapps -> Clustering

Or are you trying to share a bean across different webapps -> App server

Or are you trying to share a shared status across different webapps -> App 
server singleton

Servlet contexts... can kinda do all of the above... but its kludgy... think 
it can get very messy.

Good luck


----- Original Message ----- 
From: "Dominique Jocal" <dj...@octo.com>
To: <us...@tomcat.apache.org>
Sent: Sunday, April 08, 2007 11:09 PM
Subject: sharing same session across multiple webapp


> Hi,
>
> we'd like to make modular web development, not with merging in 1 
> deployable webapp separate web sources, but with making run 2 webapps 
> sharing the same user's session.
>
> We all know JEE standard does not specify such thing for the moment, but 
> servers start to enable it a proprietary way (see weblogic 9 for instance)
>
> Is there a way in Tomcat to share the same user's session across multiple 
> webapps, for this purpose of modular development ?
>
> Thank to any suggestion,
>
> Dominique.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org