I'm working on a Java EE web application based on Struts2(say CNG
). At a particular point, the user is redirected to a Payment Gateway (say IM
.com) and then IM
redirects to an Action of CNG
. An interceptor runs before every Action checking for the session variable and it shows a value of null
after returning from IM
.com.
Why does this happen? How can I handle this so that my session is preserved after a redirect to another application?
EDIT:
I set my session like this in an Action:
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) ActionContext.getContext().getSession();
sessionMap.put("userID","1234");
I redirect to the IM
application like this (on a JSP):
<a href="im.com/cng?q=1234">
IM
, after success payment/transaction redirect to my application - cng.com/receivePayment?p=4321
My Interceptor that runs before every action that checks for the userID in session:
public String intercept(ActionInvocation invocation) throws Exception {
// TODO Auto-generated method stub
final ActionContext context = invocation.getInvocationContext();
HttpServletResponse response = (HttpServletResponse)context.get(StrutsStatics.HTTP_RESPONSE);
SessionMap<String,Object> sessionMap = (SessionMap<String,Object>)ActionContext.getContext().getSession();
String m = invocation.getInvocationContext().getName();
System.out.println(sessionMap.get("userID"));
return invocation.invoke();
}
When IM
redirects back to CNG
the interceptor runs and prints null
i.e. I've lost my session variable..