This discussion is archived
7 Replies Latest reply: Sep 21, 2013 11:12 AM by abhi.p RSS

ApplicationSessionExpiryFilter never gets called

veenapandit Newbie
Currently Being Moderated

I have configured a Filter in the web.xml and I have a filter class.  It doesn't seem to be getting called.  I have a page just for the timeout.

 

public class ApplicationSessionExpiryFilter implements Filter {

    private FilterConfig _filterConfig = null;

 

    public void init(FilterConfig filterConfig) throws ServletException {

        _filterConfig = filterConfig;

    }

 

    public void destroy() {

        _filterConfig = null;

    }

 

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,

                                                                                                     ServletException {

        String requestedSession = ((HttpServletRequest)request).getRequestedSessionId();

        String currentWebSession = ((HttpServletRequest)request).getSession().getId();

        boolean sessionOk = currentWebSession.equalsIgnoreCase(requestedSession);

        // if the requested session is null then this is the first application

        // request and "false" is acceptable

        if (!sessionOk && requestedSession != null) {

            // the session has expired or renewed. Redirect request

          

            ((HttpServletResponse)response).sendRedirect(_filterConfig.getInitParameter("SessionTimeoutRedirect"));

        } else {

            chain.doFilter(request, response);

        }

    }

}

Please help.  We are already in production

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points