1

I found examples of programmatic login into jsf based application, like this from Balusc. Maybe it is silly question but, when I use form based authentication, I can use only a simple html form with

<input id="username" type="text" name="j_username" />
<input id="password" type="password" name="j_password"/> 

in <form method="post" action="j_security_check"> form.

I cannot use jsf form from example, why?

Community
  • 1
  • 1
Zbyszek
  • 647
  • 2
  • 8
  • 21

1 Answers1

1

Because it's not JSF who handles the login, it's the container itself. The JSF <h:form> does not allow you to specify a specific action URL. So you have to use <form>.

But your question title is confusing. Using a j_security_check form is not "programmatic login". It's "container managed login". The real programmatic login way is calling HttpServletRequest#login() yourself. You can do this in a JSF managed bean action method which is invoked by a JSF <h:form>.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Hard to admit then I feel dumb. I determine in web.xml in section /login/loginSimple.xhtml. When I try to make programmatic jsf login page whit appropirate managed bean - loginSimple.xhtml, than it not work at all :( – Zbyszek Apr 27 '12 at 13:45
  • Then you're using container managed login. You should then indeed use a plain `
    `. You do not need to do anything in JSF for this.
    – BalusC Apr 27 '12 at 13:46