Hi Michael,

this comes up every so often, so here is just the answer, which I posted
some time ago:

First of all the session is ALWAYS on application scope, this is not an
Tomcat specific behaviour but a requirement of the Specification:
"SRV.7.3 Session Scope
HttpSession objects must be scoped at the application (or servlet context)
level.
The underlying mechanism, such as the cookie used to establish the session,
can be
the same for different contexts, but the object referenced, including the
attributes in
that object, must never be shared between contexts by the container."

So there is no way around this, if the sessions were replicated across the
applications it would violate the specification.

When you enable crossConext for your application:
<Context crossContext="true" docBase="testapp" path="/testapp"
reloadable="true">
</Context>

you can get the context for another application:
ServletContext context2 = context.getContext("/testapp");

and set attributes:
context2.setAttribute("test","JSP is great!");

But you cannot get to the session in the other application.

So what you can do is implement the session swapping on your own (Cookies,
via the Database) or merge your applications into one.

Some links from the Sun Forums:
http://forum.java.sun.com/thread.jsp?forum=33&thread=259394
http://forum.java.sun.com/thread.jsp?forum=45&thread=492484
http://forum.java.sun.com/thread.jsp?forum=33&thread=318569

Cheers Bernhard


> -----Ursprüngliche Nachricht-----
> Von: Michal Kwiatek [mailto:[EMAIL PROTECTED]
> Gesendet: Donnerstag, 29. September 2005 15:34
> An: Tomcat Users List
> Betreff: session state preserved across different applications
>
>
> Dear all,
>
> How is it possible to preserve session state across different
> applications deployed in tomcat?
>
> I'm pretty sure I saw it somewhere, but I can't remember
> where it was...
>
> Thanks in advance,
> Michał.
> 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to