title: Redirect login page to another page in JSF
body: <p>I am doing a admin panel for my website.I used PrimeFaces login form for admin.I can log in and see messages.But I want to redirect page to another page after admin is logged in. I couldn't do this.How can I do?</p>
  
  <pre><code>&lt;h:form&gt;
      &lt;p:growl id="growl" sticky="true" showDetail="true" life="3000" /&gt;
  
      &lt;h:panelGrid columns="2"&gt;
          &lt;h:outputLabel for="username" value="Username:" /&gt;
          &lt;p:inputText id="username" value="#{userLoginView.username}" required="true" label="username" /&gt;
          &lt;h:outputLabel for="password" value="Password:" /&gt;
          &lt;p:password id="password" value="#{userLoginView.password}" required="true" label="password" /&gt;
  
          &lt;h:column&gt;
              &lt;p:commandButton value="Login"
                               update="growl"
                               actionListener="#{userLoginView.login}"
                               oncomplete="handleLoginRequest(xhr, status, args)" /&gt;
          &lt;/h:column&gt;
      &lt;/h:panelGrid&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  
  
  <pre><code>@ManagedBean
  public class UserLoginView {
  
      private String username;
      private String password;
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public void login(ActionEvent event) {
          RequestContext context = RequestContext.getCurrentInstance();
          FacesMessage message = null;
          boolean loggedIn = false;
  
          if (username != null &amp;&amp; username.equals("admin") &amp;&amp; password != null &amp;&amp; password.equals("admin")) {
              loggedIn = true;
              message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome", username);
          } else {
              loggedIn = false;
              message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "Invalid credentials");
          }
  
          FacesContext.getCurrentInstance().addMessage(null, message);
          context.addCallbackParam("loggedIn", loggedIn);
      }
  }
  </code></pre>