1 Reply Latest reply on Apr 23, 2012 8:34 PM by lfd

    Login Logic

      Hi all,

      I'm new to JSF and I am trying to figure out a way for my login functionality.
      I am basically doing the following:
      1. The login.xhtml contains the login form:

      <h:outputText value="#{msg.login_failed}" rendered="#{sessionManager.loginError}" />

      <p:inputText value="#{sessionManager.username}" />
      <p:password value="#{sessionManager.password}" />
      <p:commandButton value="#{msg.login}" action="#{sessionManager.login()}" update="@all" />

      2. In SessionManager I have the login logic:

      public String login() throws IOException {
      Integer sessionId = getSessionID(getUserName(), getPassword());
      if (sessionId == null) {
      else {
      return "welcome";
      return "login";

      If the authentication goes well and the sessionId is not null then I get to the welcome page.
      However if the sessionId is null I see the login page again BUT any other attempt to submit the login form would do nothing. The login method in SessionManager is not reached any more (in debug mode). Should I maybe refresh the page somehow? Please give me a hand with the flow of actions...


      Edited by: 929606 on Apr 23, 2012 9:40 AM
        • 1. Re: Login Logic
          You should read the servlet spec section on security. Do not try to create your own login process. Instead, you should follow the servlet spec and use at least declarative security that is configured by your web container.
          1 person found this helpful