title: Creating a user object from login parameters
body: <p>I'm trying to create a user object with ALL of the users fields after a user logs in so that I may retrieve any given attributes from the user's class. Here's the User class.</p>
  
  <pre><code>public class User  {
  
  private String username;
  private String password;
  private String f_name;
  private String l_name;
  private String email;
  private String dob;
  private int user_id;
  
  public User(){}
  
  public User(String username, String password)
  {
      this.username = username;
      this.password = password;
  }
  
  public User(String username, String password, String f_name, String l_name, String email, String dob, int user_id)
  {
      this.f_name = f_name;
      this.l_name = l_name;
      this.username = username;
      this.password = password;
      this.email = email;
      this.dob = dob;
      this.user_id = user_id;
  }
  </code></pre>
  
  <p>I have getters and setters for all of the fields. All users fields are also stored in an Oracle database.</p>
  
  <p>In my Java Servlet, I have the following code to create a User object and set the session attributes:</p>
  
  <pre><code>HttpSession session = request.getSession();
  
  String username = request.getParameter("username").toString();
  String password = request.getParameter("password").toString();
  
  User user1 = new User(username, password);
  
  session.setAttribute("username", username);
  session.setAttribute("password", password);
  </code></pre>
  
  <p>How can I create a user object with ALL of the user's fields based on only the username and password?</p>