I am using below to access the session data set by App1 in App2.
ServletContext sctx = ((HttpServletRequest) request).getSession().getServletContext();
String testStr = (String) sctx.getAttribute("attr");
if(testStr == null){
testStr = "test";
sctx.setAttribute("attr", testStr);
}
I get session value as below.
ServletContext sctx = ((HttpServletRequest) request).getSession().getServletContext().getContext("/app1");
String testStr = (String) sctx.getAttribute("attr");
System.out.println("the value which set in first app: " + testStr);
Actually my App2 will be in cluster environment
. In this case should App1 will also be in cluster environment?
My App2 is a web application which has few web services exposed and it does not contain any UI. There must not be any direct communication between App1 and App2. App1 has to put some value in Application scope on its start up and later App2 should access application scoped value whenever is required. Thanx
Do i have any issues in cluster environment? Is my approach correct ?
Thanks!
If:
Then your session attributes should be available across all servers.