I am having an issue with a struts 2 application. User 1 logs in successfully and is redirected to some page. After that , User 2 tries to login from her machine, she get redirected to user1's landing page.
I am not sure if that is an issue with the web container(web logic) or some issue in my coding.I am not able to figure out where I can go wrong and how the server can provide data from another users session.
The login action implements sessionaware, I have setter and getter for the session Map. If the login action returns sucesss user is redirected to another action where again the action implements sessionaware.
The problem is really weird. Can anyone suggest any reasons why it can be happening.
Also to add to the complexity , the same application ear works fine locally. The problem occurs only when I am trying to deploy it to test server.
Here is the intercepotr code. I don't think it is thread unsafe.
public class UserAuthentication extends AbstractInterceptor
{
public UserAuthentication()
{
}
public void init(){//System.out.println("init'd");
}
public void destroy() {System.out.println("destroyed");}
public String intercept(ActionInvocation invocation) throws Exception
{
String className = invocation.getAction().toString();
Map OHRMS = ActionContext.getContext().getSession();
System.out.println("EmpInfoUpd: " + new Date() + " Inside the interceptor: ");
System.out.println("EmpInfoUpd: " + new Date() + " Interceptor called for action: " + className);
System.out.println("EmpInfoUpd: " + new Date() + " Now printing the entries of session map from interceptor: " + OHRMS);
Employee temp = (Employee)OHRMS.get("emp");
if(temp==null)
{ System.out.println("EmpInfoUpd: " + new Date() + " The session had no \"emp\" object. Interceptor returned \"login\" ");
return "login";
}
System.out.println("EmpInfoUpd: " + new Date() + " The session had \"emp\" object with Employee name: " + temp.getFullName()+ " Interceptor returned \"login\" ");
return invocation.invoke();
}
}