In this post I'll show you how to redirect to the originally requested web page on Login with Shiro and Mustache. If you have a bookmark to your Site's Administration Dashboard in Chrome you want to go straight there and not back to the Home Page or somewhere else.
Shiro makes it easy with its AccessControlFilter saveRequestAndRedirectToLogin() method shown in our NixmashRoleFilter class below. NixmashRoleFilter extends Shiro's RolesAuthorizationFilter.
One of the things saveRequestAndRedirectToLogin() does in Shiro is save the original request.
We can now use the original request URL on successful login. The redirection method is actually in getRedirectUrl() at the bottom where we redirect to the Home Page if there is no existing request.
Now Mustache comes into play where we add either the original request path or the Home Page to our model, then load a good old fashioned HTML Redirect Page. You can return a Response object from the LoginController and circumvent the redirect.html page, but I like this approach.