For this to work, first on session creation, you need to set the userId attribute into session. Also, not sure, whether the OP is using struts( OP might be using other framework or no framework only), so suggesting a struts code is not a good idea.
The solution which should work for the OP problem, is use a listener and implement HTTPSessionListener and override sessionDestroyed method.
But, forwarding to a page once is session is expired is not a good idea. We had a discussion on this few days back here.
In the site, please read Rob's response to understand why this is considered bad.