Q:

Exclude some URLs from the session timeout

I have a web app with a 30 min session timeout. The design is that when the session is dropped the user is automatically logged out and needs to sign in again.
Problem is that I have a news ticker on my web page that updates every 5 minutes via an AJAX call. The newsticker AJAX call naturally resets the session timeout, so the users don't get logged out.
I was thinking of implementing my own inactivity detector by writing a filter that updates a lastActive variable (stored in the session) whenever the user gets/posts a page, except for the news ticker.
Then I was thinking, maybe there is a way to exclude certain calls from resetting the session timeout. So I searched and found some answers relating to asp, but nothing for jsp and Weblogic. 
Is there a way to exclude certain URL:s from resetting the session timeout?

A:

Since I couldn't find any way to do this by configuration I ended up writing a filter that invalidates the session when enough time has passed without user activity. I already had another filter in place that redirects users without a session to the login page. I added the SessionTimeoutFilter just before the authorisation filter in the filter chain.
The code below is slightly stripped. I have removed all internal dependencies, that is why all values are hardcoded.
public class SessionTimeoutFilter
    implements Filter
{
    private final long TIMEOUT = 1800L; // 30 minutes in seconds
    private final String LAST_ACTIVITY = "LAST_ACTIVITY";

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

        if (request instanceof HttpServletRequest) {
            HttpServletRequest theRequest = (HttpServletRequest) request;
            Long now = (new Date()).getTime();

            HttpSession session = theRequest.getSession(false);
            if (session != null) {
                Long lastActivity = (Long) session.getAttribute(LAST_ACTIVITY);

                if (lastActivity == null) {
                    // The first call for this session.
                    lastActivity = now;
                }
                if (now - lastActivity > TIMEOUT*1000L) {
                    // User timed out.
                    session.invalidate();
                } else if (isUserCall(theRequest)) {
                    // Reset inactivity timer
                    session.setAttribute(LAST_ACTIVITY, now);
                }
            }
        }
        chain.doFilter(request, response);
    }

    /** 
     * @return true  if the URI indicates user activity, 
     *         false if it is an automatic call
     */
    private boolean isUserCall(HttpServletRequest request) {
        String uri = request.getRequestURI();
        if (uri.contains("NewsTicker")) {
            return false;
        }
        return true;
    }

