title: Can I use JSF flash to pass parameters to a Servlet?
body: <p>To pass a hidden parameter from a JSF 2.0 Managed BEan action handler to a Servlet, I pass the parameter value into a Session attribute:</p>
  
  <pre><code>public void callServlet(long id) {
    try {
      ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
      HttpSession sess = (HttpSession) ctx.getSession(false);
      sess.setAttribute("id", id);
      ctx.redirect("MyServlet");
    } catch (IOException ex) {
      Logger.getLogger(ResultBean.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
  </code></pre>
  
  <p>Are there better ways to do this, for example is it possible to use the flash map to send this hidden parameter to the Servlet?</p>