I have a web-based service implemented in Tomcat and using Tomcat container-based authentication. What I’m trying to achieve is to have the login page appear differently depending on how the user got there. Specifically:
-
If the user clicks on the “login” button, I want the login page to just ask for a username and password. I’ve implemented the login button to simply take the user to the “logged in” page, and made that a secure page so that container login gets triggered.
-
If an unauthenticated user visits a page that requires authentication, I want the login page to also say “You must login to do this” or something like that.
So the problem is to make the controller or JSP for the login form aware of what the browser was requesting when it got redirected here. I’ve looked at the headers and other attributes in the request object, but I couldn’t see anything that would help.
Can anyone suggest a solution? Or maybe a different way to implement the “login” button that would avoid the problem?
You can use this to determinate the target of the original request:
Other options include:
You could implement the login button to redirect to the
login success pageand add a?MyKey=valueto the URL, that attribute can be seen by thelogin pageand you can react on it.I will work over my code that plots out everything and anything I could find and make it better readable and then post it here. I’m sure that the value where the user gets next is present somewhere in your
request, you just have to find out where.