Search code examples
jakarta-eej-security-check

How to redirect to url after j_security_check login


I use j_security_check to authenticate my Java EE web app.

I have 2 groups; user and admin. Both of these groups have a own folder in the weg pages; user has "/secure", admin has "/admin". After a person is authenticated with j_security_check I would like based on their group to redirected to their associated web folder. Now they just stay at the login page. The authenticating part of my app works fine, if I log in as an user I can access /secure but not /admin, and vice versa.

Is this possible and how? I coulden't find any information or a solution online.

Edit: Maybe some handy information for a solution, I also use JSF in my app. But I don't use any JSF to login. Login form is pure html with the j_security_check stuff.

Edit 2: The root file for my main web folder is the login page.


Solution

  • For anyone wondering how I solved it, I forgot to specify the roles in the web.xml, like this:

    <security-role>
        <role-name>admin</role-name>
    </security-role>
    <security-role>
        <role-name>skipper</role-name>
    </security-role>
    

    Thanks @Franck for taking his time to solve this problem trough chat!