1

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!

Gurminder Singh
  • 1,755
  • 16
  • 19
  • Hey Gurminder, I'm having exactly the same issues as u, with appfog and spring. In my case when I login and change to another page or load a resource, the jsessionid changes (every 1-5 requests), so my session is recreated. Did u find out a solution?, maybe is an appfog bug. – maqjav Sep 28 '13 at 16:59
  • Not yet @maqjav and nobody has the answer on stackoverflow and elsewhere. I believe you are right. May be an appfog bug. – Gurminder Singh Sep 28 '13 at 17:03
  • I opened a ticket in Appfog, let's see if I get an answer, although being a free account it will take a while to get an answer. I'll keep you posted. – maqjav Sep 28 '13 at 17:14
  • Ok @maqjav. Thanks for giving your time! – Gurminder Singh Sep 28 '13 at 17:46
  • Hey @Gurminder Singh. I got answer from the support, and they have escalated the issue to make some tests. As soon as I get the answer I will let you know. – maqjav Oct 06 '13 at 10:04
  • Ok @maqjav, thanks for keeping me informed! :) – Gurminder Singh Oct 06 '13 at 13:58
  • u know what? it does it in php as well ... avery 1-5 the PHPSESSID gets flushed and replaced with a new one. As a results the state gets lost and I get pissed off! DAMN IT! – nourdine Jan 19 '14 at 21:56

1 Answers1

0

Which kind of servlet specification does AppFog support? If I'm not wrong, spring mvc Interceptor are supported on servlet >=2.3

Angelo Immediata
  • 6,635
  • 4
  • 33
  • 65
  • I don't know in detail, but, I guess AppFog supports only upto 2.5 specification. However, according to me, the interceptors are working fine because if they wouldn't, app shouldn't have been redirecting to the home page. – Gurminder Singh Sep 20 '13 at 09:54