title: JSF Starting Page Redirect via f:event listener
body: <p>In my application after the user has logged in, he is redirected to a specific page according to his role.
  Since the upgrade from Primefaces 6.0 to Primefaces 8.0 the redirect implemented via f:event listener does not work any more. With 8.0 I get the following exception:</p>
  <pre><code>JBWEB000069: description JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request.
  
  JBWEB000070: exception 
  javax.servlet.ServletException
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
  
  JBWEB000071: root cause 
  java.lang.IllegalStateException
      org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:420)
      com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:602)
      eu.companyXY.qkb.br.web.session.BrUserSession.redirect(BrUserSession.java:86)
      eu.companyXY.qkb.br.web.session.BrUserSession$Proxy$_$$_WeldClientProxy.redirect(BrUserSession$Proxy$_$$_WeldClientProxy.java)
      eu.companyXY.qkb.br.web.target.**BrTargetBean.doRedirect**(BrTargetBean.java:98)
      javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2485)
      javax.faces.event.SystemEvent.processListener(SystemEvent.java:106)
      com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2166)
      com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2111)
  </code></pre>
  <p>The method <strong>doRedirect</strong> is called in index.xhtml:</p>
  <pre><code>&lt;f:metadata&gt;
      &lt;f:event listener=&quot;#{targetSelect.doRedirect}&quot; type=&quot;preRenderView&quot; /&gt;
  &lt;/f:metadata&gt;
  </code></pre>
  <p>and finally here is the method BrTargetBean.doRedirect:</p>
  <pre><code>public void doRedirect(ComponentSystemEvent event) {
      ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
      ec.redirect(ec.getRequestContextPath() + &quot;/main/br/datacorrections.xhtml&quot;);
  }
  </code></pre>
  <p>With Primefaces 6.0 this code worked without any problem.
  Do you have any idea about what's going wrong here ?</p>
  <p>Also if you know another way of redirecting to a specific page after login please let me know.</p>
  <p>Thanks in advance for your help</p>