title: Acces one managed bean from another by @ManagedProperty
body: <p>I have 2 jsf pages and 2 beans for each. 
  First page is login page, where user types his login-password and then he is redirecting to his mailbox page. I want to get data from login page to mailbox page. </p>
  
  <p>My bean for login page:</p>
  
  <pre><code>@ManagedBean(name = "login")
  @ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
  @RequestScoped
  public class LoginFormBean {
  
      @EJB
      private LoginService loginService;
  
      private String email;
  
      private String password;
  
      public String getEmail() {
          return email;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String login() {
          if (loginService.loginUser(email, password))
            return "mailBox.xhtml?faces-redirect=true";
          else return "";
      }
  
  }
  </code></pre>
  
  <p>My bean for mailbox page:</p>
  
  <pre><code>@ManagedBean(name = "mailBox")
  @ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
  @RequestScoped
  public class MailBoxFormBean {
  
      @ManagedProperty(value = "#{login}")
      private LoginFormBean login;
  
      private String email = login.getEmail();
  
      public void setLogin(LoginFormBean login) {
          this.login = login;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getEmail() {
          return email;
      }
  }
  </code></pre>
  
  <p>But when I'm redirecting to mailbox page, login bean is null and I can't get data from it. 
  What I'm doing wrong?</p>
  
  <p>I've seen a lot of tutorials and answers (for example, 
  <a href="https://stackoverflow.com/questions/8969791/using-managedproperty-to-call-method-between-managed-beans">Using @ManagedProperty to call method between Managed beans</a> or
  <a href="http://www.techartifact.com/blogs/2013/01/access-one-managed-bean-from-another-in-jsf-2-0.html" rel="nofollow noreferrer">http://www.techartifact.com/blogs/2013/01/access-one-managed-bean-from-another-in-jsf-2-0.html</a>
  )</p>
  
  <p>I do exactly the same, but it isn't working for me.</p>