title: Create example simple with MVC Java
body: <p>I have a simple example to check login of user using MVC Model..</p>
  
  <p>LoginModel:</p>
  
  <pre><code>public class LoginModel {
  private String username;
  private String password;
  
  public LoginModel()
  {        
  }
  /**
   * @return the username
   */
  public String getUsername() {
      return username;
  }
  /**
   * @param username the username to set
   */
  public void setUsername(String username) {
      this.username = username;
  }
  /**
   * @return the password
   */
  public String getPassword() {
      return password;
  }
  /**
   * @param password the password to set
   */
  public void setPassword(String password) {
      this.password = password;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>LoginView:</p>
  
  <pre><code>public class LoginView {
  LoginModel user;
  
  //Ham khoi tao cho LoginView
  public LoginView(LoginModel user)
  {
    this.user=user;
  }
  
  public void showMessage(String msg)
  {
    System.out.println(msg);
  }
  
  public void getUserInfo()
  {
  try
  {
  
      DataInputStream input=new DataInputStream(System.in);
      System.out.println("Username:");
      user.setUsername(input.readUTF());
      System.out.println("Password:");
      user.setPassword(input.readUTF());
      input.close();
  }
  catch(IOException e)
  {
      System.out.println(e);
  }
  </code></pre>
  
  <p>}
  }</p>
  
  <p>LoginControl:</p>
  
  <pre><code>public class LoginControl {
  LoginModel user;
  LoginView view;
  
  public LoginControl(LoginModel user,LoginView view)
  {
      this.user=user;
      this.view=view;
      while(true)
      {
      view.getUserInfo();
      if(checkLogin())
      {
          view.showMessage("Success");
      }
      else
      {
          view.showMessage("Wrong username or password");
      }
      }
  }
  
  private boolean checkLogin()
  {
      if((user.getUsername().equals("sa"))&amp;&amp;(user.getPassword().equals("sa")))
      {
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>LoginMain:</p>
  
  <pre><code>public class LoginMVC {
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
      // TODO code application logic here
      LoginModel user=new LoginModel();
      LoginView view=new LoginView(user);
      LoginControl control=new LoginControl(user, view);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>But when I run main class,It's only username: and input user and stop..
  I don't known where is error.
  Can you help me.</p>