posted 18 years ago
You can't. We're dealing with a stateless protocol, which means the server can only respond when the browser requests a page. The server is not allowed to "push" a response to the browser without having received a request!
Think about what happens during a session timeout. It means the browser hasn't requested anything from the server in a long time. No request means no response.
There's a couple ways around the problem:
One is that you can add javascript to the pages to perform the forwarding, using the same amount of time as used for session timeouts.
Another solution is to use an Intercepting filter. The filter can check if a session exists and, if the session doesn't exist, forward the user to the special jsp. The user won't know that the session timed out until they submit a request after the timeout, but it works.
A good workman is known by his tools.