post login operation with j_security_check
-
09-02-2021 - |
Question
I am using form-based authentication and j_security_check in my j2ee application which runs on glassfish 3.1. Problem is when login succeed I have to update some data related to authenticated user. How to make post-login operation after j_security_check ends it's execution? Thanks.
Solution
A workaround with Servlet 3.0 (or Java EE 6): Call HttpServletRequest.login()
from a managed bean and if it doesn't throw an exception do your post login operations.
OTHER TIPS
Create a filter which is mapped to
j_security_check
You need to overwrite the
Origin
header of the response beforechain.doFilter(request, response);
of that filter and also to place your post redirect URL in the cookieWASReqURL
(Or the cookie of glassfish that holds the next url)The link you chose in step 2 need to be mapped to a servlet which executes the post-j_security_check stuff and afterward, to redirect back to the overwritten link from step 2.