title: Storing values in arraylist and printing it
body: <p>i am storing logged in user name in arraylist and than putting the arraylist in session .Whenever the user logged in for the first time it is printing the user name but when refreshing the page the same name is printing twice but i only want to print the username only one time no matter how many times the user refresh the page please help </p>
  
  <pre><code>String username = request.getParameter("username");
              String password = request.getParameter("password");
  
  
  HttpSession session = request.getSession(true);
  
          session.setAttribute("username", username);
          session.setAttribute("password", password);
          response.setContentType("text/html");                  
          ArrayList&lt;user&gt; users = (ArrayList&lt;user&gt;) sc
                        .getAttribute("users");
  
                if (users == null) {
                    System.out.println("loggedInUsers creates");
                    users = new ArrayList&lt;user&gt;();
  
                }
                users.add(new user(Name, U_ID, Pass));
  
                sc.setAttribute("users", users);
  
  
                users = (ArrayList&lt;user&gt;) sc.getAttribute("users");
  
                for (int i = 0; i &lt;= users.size() - 1; i++) {
                    user user = users.get(i);
                    out.println(user.getUserName()+ "&lt;br&gt;");
                    //out.println("&lt;br/&gt;" + user.get(i));
                } 
  </code></pre>