Hi,

When I created 2 webapps in 1 host and I wanted to get these 2 webapps to
use 1 session.

Accordingly, I configured my server.xml like this.

 

<Host appBase="webapps" autoDeploy="true" name="localhost"
unpackWARs="true">

           <Context path=”/app1” sessionCookiePath=”/” ></Context>

           <Context path=”/app2” sessionCookiePath=”/” ></Context>

</Host>

 

Then, I made simple Servlet in each webapp.

Here are doget methods for each Servlet.

 

Servlet 1 in app1

request.getSession().setAttribute(“data”,”111”);

 

Servlet 2 in app2

request.getSession().getAttribute(“data”);

 

But I failed to get data from session in app2, it always returned null.

Finally, I started my tomcat in debug mode and checked each session object.

 

one session was 

StandardSession[3A359FF7CCC02303335DA09EDD569F0A]

org.apache.catalina.session.StandardSessionFacade@2d517aa8

and it had some attributes.

 

another was

StandardSession[3A359FF7CCC02303335DA09EDD569F0A] <<<<same session ID!!??

org.apache.catalina.session.StandardSessionFacade@3e322634 <<< but not
façade… LOL

and it had no attributes.

 

In spite of same session ID, but why this situation happened?

and how can I get these two webapps to share session?

Thanks J

Reply via email to