post login operation with j_security_check

2k views Asked by At

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.

2

There are 2 answers

2
palacsint On BEST ANSWER

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.

2
Hesham Yassin On
  1. Create a filter which is mapped to j_security_check

  2. You need to overwrite the Origin header of the response before chain.doFilter(request, response); of that filter and also to place your post redirect URL in the cookie WASReqURL (Or the cookie of glassfish that holds the next url)

  3. 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.