I am working on a java web application developed using Spring MVC-Hibernate. The application works fine when deployed on Glassfish-3.1.2 and Tomcat-6/7. However, when the application is deployed on AppFog(Website Hosting application), it is unable to hold the session i.e the user logs into the application ,but, when he clicks on any link he is redirected back to the login page.
This happens because I have created an interceptor(SessionInterceptor) to check the user session on every request which redirects the application to the login page in case the session has expired. Following is the code which I have written in the preHandle() method of my SessionInterceptor class:
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
HttpSession session = request.getSession();
if(!(handler instanceof HomeController || handler instanceof ForgetPasswordController)) {
if(session.getAttribute("user") == null) {
response.sendRedirect(request.getContextPath()+"/"+redirectMapping+"?msg=e");
return false;
} else {
return true;
}
} else {
return true;
}
}
I don't have any clue why this is happening on AppFog. Any help gratefully appreciated. Thanks in advance!