You can try using this one. This isnt exactly what you want, but something similar. Clicking on a button takes you to another page. Here you have another button. You either click it within a certain time interval, or you get timed out and sent to a different page.
Hope this helps you.
I'll just give you the relevant servlet code. The rest (mapping, jsp etc) should be easy.