title: Data transfer between JSF pages in separate projects
body: <p>Two JSF/JSF pages and associated managed beans in two separate projects (maybe different servers)
  Name them PageA.jsp and PageB.jsp with BackingBeanA.java and BackingBeanB.java (again, separate projects)</p>
  
  <p>Desire is to redirect from PageA.jsp to PageB.jsp and pass an object (FilterData)</p>
  
  <p>The following was tried:</p>
  
  <p>BackingBeanA.java</p>
  
  <pre><code>public String startPageB() {
  
      try {
  
      FilterData filterData = ...
  
          FacesContext facesContext = FacesContext.getCurrentInstance();
  
          HttpServletRequest request = (HttpServletRequest) 
              facesContext.getExternalContext().getRequest();
          request.setAttribute("FILTERDATA",filterData);
  
          ExternalContext externalContext = facesContext.getExternalContext();
          externalContext.setRequest(request);
  
          externalContext.redirect("http://localhost:8080/PageB/");
  
      } 
      catch (IOException e) {
          e.printStackTrace();
          System.out.println(e);
      }
  
      return "redirectedData";
  }
  </code></pre>
  
  <p>BackingBeanB.java (in a separate project, could be separate server)</p>
  
  <pre><code>public String getBeanAData() {
  
      FacesContext facesContext = FacesContext.getCurrentInstance();
  
      HttpServletRequest request = (HttpServletRequest) 
          facesContext.getExternalContext().getRequest();
  
      FilterData newFilterData = (FilterData) 
          request.getAttribute("FILTERDATA");
  
  ... do stuff
  return null;
  }
  </code></pre>
  
  <p>Result:
      getBeanAData is called, however:
      filterData was not null in BackingBeanA, but was null in BackingBeanB - data was not transferred.</p>
  
  <p>Any ideas as to how to properly do this data passing?</p>
  
  <hr>
  
  <p>What I should have included in the original question:</p>
  
  <p>Java 1.6.0_22-b03
  JSF 1.2
  JSTL 1.2
  Eclipse 3.6.0 (Helios)
  Tomcat 6.0.28 (needs to run also on Weblogic)
  IE 7.0.5730.13
  Firefox: 3.6.12</p>
  
  <p>Attempt is to be pure JSF if possible, no HTTP desired (but possible), no JavaScript (period).</p>
  
  <p>How I solved the problem (good enough for now):</p>
  
  <p>From parent web page -</p>
  
  <pre><code>...
  
          FacesContext facesContext = FacesContext.getCurrentInstance();
          ExternalContext externalContext = facesContext.getExternalContext();
  
          String initialUrl = externalContext.getInitParameter("RedirectUrl");
  
          String requestDataA = "?ValueA=" + activity.getID();
          String requestDataB = "&amp;ValueB=" + activity.getName();
  
          redirectUrl = initialUrl + requestDataA + requestDataB;
  
          externalContext.redirect(redirectUrl);
  ...
  </code></pre>
  
  <p>From redirected web page -</p>
  
  <pre><code>...
          String ownerName = (String) FacesContext.getCurrentInstance().
             getExternalContext().getRequestParameterMap().get("ValueB");
  
          String itemId = (String) FacesContext.getCurrentInstance().
             getExternalContext().getRequestParameterMap().get("ValueA");
  ...
  </code></pre>
  
  <p>Result is that this works great - for strings.  This is OK for now.</p>
  
  <p>What I would like for later if possible:</p>
  
  <pre><code>The same thing, but passing an object.  
  I know I cannot do that on the request line, but I thought there was a way
  similar to a standard HTTP setup where a request attribute is set and the
  destination page gets it with a doPost method (do I have this wrong?).
  
  The BalusC answer indicates this is not possible.  
  So is it really not possible to have a JSF page redirect (starup or whatever) 
  to an external page, and pass it an object without going to shared storage?
  </code></pre>
  
  <p>Thanks,
  John</p>