title: JSF - Get the SessionScoped Bean instance
body: <p>I have this configuration on my web application. 2 beans :</p>
  
  <p>1° Bean - It checks the login;</p>
  
  <pre><code>@ManagedBean(name="login")
  @SessionScoped
  public class Login {
      private String nickname;
      private String password;
      private boolean isLogged;
  
      public String getNickname() { return nickname; }
      public void setNickname(String newValue) { nickname=newValue; }
  
      public String getPassword() { return password; }
      public void setPassword(String newValue) { password=newValue; }
  
      public void checkLogin() {
          ... i check on db the nickname and the password ...
  
          if(USER EXIST) {
              isLogged=true;
          } else {
              isLogged=false;
          }
  
          return true;
      }
  }
  </code></pre>
  
  <p>2° Bean - Manage User parameter :</p>
  
  <pre><code>@ManagedBean(name="user")
  @SessionScoped
  public class User {
      private String name;
      private String surname;
      private String mail;
  
      public User() {
          String[] record=null;
          Database mydb=Configuration.getDatabase();
          mydb.connetti();
          ArrayList&lt;String[]&gt; db_result=null;
          db_result=mydb.selectQuery("SELECT name, surname, mail, domicilio FROM users WHERE nickname='???????'");
  
          int i = 0;
          while (i&lt;db_result.size() ) {
             record=(String[]) db_result.get(i);
             i++;
          }
      }
  
      ... getter and setter methods...
  }
  </code></pre>
  
  <p>As you can see, I would like to know how get the nickname setted previously on my <code>login</code> bean, so i can do the query on my DB. </p>
  
  <p>In fact i need to get the instance of the current-session bean login : how can I get it? I should use somethings like <code>session.getBean("login")</code> :)</p>
  
  <p>Hope this question is clear :)</p>