I have been keeping an eye on this thread because I have a similar issue
which I raised under a separate thread on Friday. I note your comments re
crossContext and use of context.getContext("name"). Please can you tell me
the conditions under which this will NOT work ? I am attempting to do
exactly what you suggest but I always get null returned from the
getContext.  (This is an application which worked perfectly under Tomcat
4.1.27 and now does not work under 5.5.9)
Thanks.

Irene Hall




                                                                       
                              Bernhard                                 
                              Slominski            To:   "'Tomcat Users List'" 
<users@tomcat.apache.org>
                              <bernhard.slomi      cc:                 
                              [EMAIL PROTECTED]      bcc:                
                              m>                   Subject:    AW: Sync session 
across webapps
                                                                       
                              21/11/2005                               
                              09:56                                    
                              Please respond                           
                              to "Tomcat                               
                              Users List"                              
                                                                       
                                                                       




Hi Mathew,

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: Mathew Joseph [mailto:[EMAIL PROTECTED]
> Gesendet: Montag, 21. November 2005 09:37
> An: users@tomcat.apache.org
> Betreff: Sync session across webapps
>
>
> Hi,
>
> In my web application there are 2 webapps and single login for both.
> And in UI we are given links to different modules of both webapps.
> Actually the end user is not (should not be) aware of 2 webapps.
>
> The problem what I am facing is, If someone try to work/use
> continuously
> in one webapps and try to click a link from other webapp and
> if it exceeds
> the session timeout period then user is forced to login
> again. Is there anyway
> to avoid this OR is there any way to synchronize session
> across webapps ?
>
> I am using Tomcat 5.5.7 and Struts Framework 1.1.
>
> Thanks in advance...
> Mathew
>

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







For more information on Standard Life, visit our website
http://www.standardlife.co.uk/

The Standard Life Assurance Company, Standard Life House, 30 Lothian Road,
Edinburgh EH1 2DH, is registered in Scotland (No. SZ4) and is authorised
and regulated by the Financial Services Authority. Tel: 0131 225 2552 -
calls may be recorded or monitored. This confidential e-mail is for the
addressee only. If received in error, do not retain/copy/disclose it
without our consent and please return it to us. We virus scan and monitor
all e-mails but are not responsible for any damage caused by a virus or
alteration by a third party after it is sent.


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

Reply via email to