Have a queue into which you put the current URI. Make it x long and the queue should drop older items as it grows.
Having an abstract base for your
servlets which handles this for you is the best way to guarantee it's implemented globally.
Then simply iterate over the queue (without deleting items) and display the results.
An included
JSP fragment will handle that consistently for all pages.