title: How can I navigate to another page in managed bean?
body: <p>I am trying to forward a page in my managed bean with the commandbutton:</p>
  
  <pre><code>&lt;h:commandButton action="#{bean.action}" value="Go to another page" /&gt;
  </code></pre>
  
  <p>The following line:</p>
  
  <pre><code>public void action() throws IOException {
      FacesContext.getCurrentInstance().getExternalContext().redirect("another.xhtml");
  }
  </code></pre>
  
  <p>redirects the page, not forwards. I have seen a similar question to this and tried the given solution:</p>
  
  <pre><code>public void action() throws IOException {
      FacesContext.getCurrentInstance().getExternalContext().dispatch("another.xhtml");
  }
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <pre><code>Index: 0, Size: 0
  </code></pre>
  
  <p>So how can I forward to a page from a managed bean?</p>