This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I'm working on medical test software. You log in, and you have a number of menu choices on the left: Patients, Reports, Clinicians, etc...
Let's say a user clicks Patient, pages through the table to the third set of entries, clicks Reports, and then clicks back on Patient. By default, they get returned to the first page of the Patient table again. It would be much more convenient for them to be returned to the page of Patient they were most recently on.
I have a working solution, but it seems a little awkward and I'd like to see if something more straightforward exists. Create a session attribute "menu locations" that is a Map. The Map keys are the menu choices, "Patients", "Reports", "Clinicians", etc... The Map values are the most recent HttpServletRequest.getQueryString() values when the user navigated through the corresponding menu. Each time the user clicks a menu item, check the request query string. If it is non-null, simply save it in the session Map and continue normally. If it is null, check the session Map for a value for that menu. If you find one, forward to that location.