Aquí es cómo usted puede código que he estado haciendo durante otro poco de trabajo que estoy trabajando ....
Primera actualización
/etc/tomcatx/server.xml
para cada contexto que requiere para ser compartido
<Context path="/servlets" crossContext="true"..
<Context path="/solutions2" crossContext="true"..
Añadir la crossContext = true etiqueta para cada contexto ahora para el código para crear y enviar información de la sesión compartida
..................................
El código para modificarlo ..
//Context 1 : Sending Servlet Add below
//So this is AuthSuccess - Within The master context doing authentication
//Given examples of vectors sessions and request from
//All the information now allows you to put those new
// provider and providerName session values back into AuthSuccess
//that is executed on other Context -
//In theory once it authenticates you can just store the output i.e.
//email/display/logged in and put it into other context - or...
//as it is process list etc on other context
//Vector example
Vector roles=new Vector();
roles.addElement("COOOGOOO");
//Redirect url
String redir="http://mydomain.com/solutions2/AuthSuccess";
//Get session id
String sessionid = session.getId();
HttpSession session = req.getSession(true);
session.putValue("provider2","provider_session_info");
session.putValue("providerName2","providerName");
//Start new shared servlet context
ServletContext myContext = getServletContext();
//Shared sessioname is obvious and it sends the session id followed by:
// objects,string,sessions,whatever that matches other end
myContext.setAttribute("MYSHAREDSESSION", sessionid);
myContext.setAttribute("GOOFY",roles);
//Send session directly
myContext.setAttribute("SharedSession",session);
//send HttpRequest
myContext.setAttribute("SharedRequest",request);
//Redirect to new context/domain/subdomain
Redirect(out,red,response);
//-------------------------------------------------------------
// Now within ther servlets of solution2 within
// AuthSuccess call back the session info
// and process as per normal
//Add this to new context path
//So it looks in the first context now
ServletContext firstOne = getServletContext().getContext("/servlets");
//returns previous session id
String jsessionid= (String)firstOne.getAttribute("MYSHAREDSESSION");
//Returns Session as was
Session ProviderName=(Session)firstOne.getAttribute("SharedSession");
//Returns session strings we need
String g1=(String)ProviderName.getValue("provider2");
String g2=(String)ProviderName.getValue("providerName2");
pout +="---
"+g1+"
"+g2;
//Grab previous request to do req processing if required
HttpServletRequest nrequest=(HttpServletRequest)firstOne.getAttribute("SharedRequest");
//retrieve vector
Vector goo= (Vector)firstOne.getAttribute("MYVECTOR");
if (goo.size()>0) {
for (int a=0; a";
}
}
¿Quieres pasar el hecho de que están autenticados, o el contenido de la sesión? – Yishai
intente OpenSSO para una solución más general – IAdapter
vea también: http://stackoverflow.com/questions/665941/any-way-to-share-session-state-between-different-applications-in-tomcat –