Sharing session
Hi,
i m using tomcat 5.0.28. i have tow web applications deployed in server, say A1 and A2.
i hv login page in both A1, and A2. and welcome pages following by them.
in A1, i have a link to the welcome page of A2. in Welcome pages i m siply displaying the user name, which is stored in the session variable of the application.
UID-password combination checking allows to view welcome page if both UID and PWD are same like "tiger", "tiger".
What i need is to get the session variable for user( in A1) in A2. And the welcome page should display that user name.
In both welcome pages i m checking the session variable's value. if this is null, user will directed to the Corresponding Login Pages.
the variable name should be "MY_USER" in both application.
How can i share session among applications
p()()ja
[867 byte] By [
_Poojaa] at [2007-10-2 13:02:55]

hi,>A session can be cloned into a second running copy of the same >webapp on another JVM, but a session is confined to one webapp.As i mentioned, i have both application in same server, same JVM.p()()ja
> hi,
> >A session can be cloned into a second running
> copy of the same
> >webapp on another JVM, but a session is
> confined to one webapp.
>
> As i mentioned, i have both application in same
> server, same JVM.
>
> p()()ja
The answer remains the same, you cant in any straight forward manner.
There is a method in ServletContext,
getServletContext(String otherconText)
You can try getting a handle to the other context (webapp) this way and then get a handle to that context's session object.
Do note, this api is server dependent and many servers may optionally choose not to implement it (security concerns)
The ideal way to go about it would be to store mutually shareable data in a db/xml and then pass along the ids between the 2 web applications.
Finally note that this is a possible feature in j2ee 5.0 :)
cheers,
ram.