Performing user authentication in Java EE / JSF using j_security_check
I tried this solution. But if i put this to my config
<login-config>
<auth-method>FORM</auth-method>
<realm-name>sql</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/index.xhtml</form-error-page>
</form-login-config>
</login-config>
instead of
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>sql</realm-name>
</login-config>
the login popup of basic auth doesn’t show up anymore.. which was what i aspected.
But the Login Page which then comes has no Inputfields.. none of the faclet code had been executed. how could that be?
my login.xhtml code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Login</title>
</h:head>
<h:body>
<form action="j_security_check" method="post">
<h:outputLabel for="j_username">Username:</h:outputLabel>
<h:inputText id="j_username" required="true" />
<h:message for="j_username" />
<br />
<h:outputLabel for="j_password">Password:</h:outputLabel>
<h:inputSecret id="j_password" required="true" />
<h:message for="j_password" />
<br />
<h:commandButton value="Login" />
</form>
</h:body>
</html>
Thats all what is displayed
Username:
Password:
In other words, the
FacesServletis not been invoked. As another evidence, rightclick page in browser, choose View source and you’ll see that JSF tags are not been processed. TheFacesServletis the one responsible for that.You need to change the URL of the login page to match the
url-patternof theFacesServlet. If that is for example*.jsf, then update as follows: