Hi Alain, 

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: Alain Gaeremynck [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 14. September 2005 03:03
> An: Tomcat Users List
> Betreff: cross context info
> 
> 
> I have 2 webapps living on the same server and they are linked to the 
> same user experiance..  Now both apps require login but i 
> don't want my 
> users to have to login on both apps.  Also while they are browsing in 
> one context i don't want the session to expire for the other context. 
> 
> so the question is  Is there a way to do session.setAtribute in one 
> context and retrieve it from another and also to link the 2 
> session so 
> that they don't expire or expire at the same time? 
> 
> i'd like not to have to use hidden iframe and stuff like that
> 
> thanks!
> 
> -- 
> Alain Gaeremynck
> CTO Le Groupe Interstructure
> (514) 374-1110
> (514) 825-7810 cell
> weblog: http://www.sanssucre.ca
> (En informatique, comme en musique, n'importe quoi sauf du commercial)
> 
> 
> ---------------------------------------------------------------------
> 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