How to implement redirect to login-page with Java EE 6/Glassfish

前端 未结 1 1591
旧时难觅i
旧时难觅i 2021-01-01 06:13

I\'m trying to implement a redirect after login, which means I can\'t use glassfish built-in form authentication settings anymore that handles such things automatically. So

相关标签:
1条回答
  • 2021-01-01 06:53

    In your customized login form, add the following hidden field:

    <input type="hidden" name="from" value="#{requestScope['javax.servlet.forward.request_uri']}" />
    

    which you set in JSF as follows

    @ManagedProperty(value="#{param.from}")
    private String from;
    

    and redirect as follows in login action method

    if (from != null) {
        externalContext.redirect(from);
    }
    

    No need for a Filter.

    0 讨论(0)
提交回复
热议问题