Hi,
I posted the same question, and didn't get an answer, so I just did some
research on my own:
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 relicated 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
Please correct me, when I was wrong!
Cheers Bernhard
-----Urspr�ngliche Nachricht-----
Von: Rainald Suchan [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 16. April 2004 11:50
An: [EMAIL PROTECTED]
Betreff: Tomcat 5, cross context problem
Hi,
I have 2 web applications, a JSP and a Servlet, that are in differed
contexts. For both I have set cross context to true. In the JSP I put
some attributes in the session and use a RequestDispatcher and call the
include() function to pass the request to the servlet. In the servlet I
get these attributes out of the session and put some other attributes in
the session. After returning to the JSP I get these new attributes again
out of the session. This all works ok with Tomcat 4. But now I tried
this with Tomcat 5.0.16 and the session passed between the two webapps
don't have the attributes in it any more in the other context. That
means If I put an attribute in the JSP in the session and get this
session back in the Servlet then this session doesn't contain my
attribute any more.
Is that a known issue with Tomcat 5?
Does anybody have a solution for this problem?
Regards
Rainald
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]