It seems like you are trying to write a program that needs to be notified when the Session Expires or is Invalidated.
Apart from Filters, there are ServletListeners too that could resolve your problem. (hopefully)
Try implementing a javax.servlet.http.HttpSessionListener & declare the same in your deployment descriptor. You need to provide implementation for 2 of its mandatory methods sessionCreated() & sessionDestroyed(). For your requirement, The sessionDestroyed() is passed a HttpSessionEvent Object by the container. You can retrieve the session related stuffs (seriously) from this object.
Any good HttpServlet material will give you an example implementation of HttpSessionListener. Just follow it & do whatever you want in those 2 methods.
Have a Good Time Ahead