Is that possible to retrieve the user’s requested URL before the JAAS redirect it?
my web.xml is like this:
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsf</form-login-page>
<form-error-page>/login.jsf</form-error-page>
</form-login-config>
</login-config>
So, when I’m not logged and try to go at ex. www.blah.com/myApp/users.jsf
then the app redirect me to login.jsf but the url still the same that the user requested.
then I fill the login form and click Login, that goes to my backbean where a call my loginModule and callbackHandler ex.:
public String actionLogin(){
//do my login and stuff
return "page that user requested";
}
I tried many ways to get the user’s requested page. request.getRequestURL()
all returned me : www.blah.com/myApp/login.jsf
any way to get the requested page? www.blah.com/myApp/users.jsf
regards
The login page is internally opened by a server-side forward by
RequestDispatcher#forward(). This thus means that the initially requested page is available as a request attribute with the name as specified inRequestDispatcher.FORWARD_REQUEST_URIconstant. In JSF terms, that’s thus available as follows:(keep in mind to have a fallback URL for the case it returns
null, i.e. when it’s been opened directly without hitting a restricted URL first)The best place to collect it would be the (post)constructor of a
@ViewScopedbean associated with the login page.See also: