<p>Ok simple question. I have a JSF application, containing a login page. The problem is if the user loads the login page, leaves it for a while, then tries to login the session expires and a ViewExpiredException is thrown. I could redirect back to the login when this happens, but that isn't very smooth. How can I allow this flow to properly login without an additional attempt?</p>

Couple of slightly hacky solutions:
(Very hacky) use a
```
<meta http-equiv="refresh" content="5"/>
```
tag to automatically reload the page every so often.
Use a JavaScript function to periodically send a 'ping' request to the server to keep the session alive.
We use
IceFaces
at work which automatically detects when your session has expired and displays a pop-up alerting you to the fact. But we do still sometimes have problems on the login page for some reason.