Arraylist gets same values for all rows in all array positions
<p>Arraylist gets values from database. its fine. but after completing 3 loops(3 records in database) finally arraylist should contain all 3 rows containing 2 columns in each. <strong>Arraylist gets 3 rows but all column values are same.</strong></p>

<p>i got this</p>

<pre><code>Arraylist [0] email : abc@gmail.com pwd : abc123
          [1] email : abc@gmail.com pwd : abc123
          [2] email : abc@gmail.com pwd : abc123
</code></pre>

<p>it want this</p>

<pre><code>Arraylist [0] email : abc@gmail.com pwd : oih123
          [1] email : iii@yahoo.com pwd : nbh435
          [2] email : nbh@mail.in pwd : www123
</code></pre>

<p><strong>Controller</strong> </p>

<pre><code>arraylist = new ArrayList();
        ModelAndView model = new ModelAndView();
        try {

            modelclass obj = new modelclass();
            SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
            dataSource = new dbconnection.connection().getConnection(dataSource);
            JdbcTemplate jt = new JdbcTemplate(dataSource);
            String sql = "SELECT * FROM user_info";
            srs = jt.queryForRowSet(sql);

            while (srs.next()) {
                 obj.setEmailid(srs.getString("email_id"));
                obj.setPwd(srs.getString("pwd"));
                arraylist.add(obj);  //i++;
            }
            model.addObject("arraylist", arraylist);
 return model;
</code></pre>

<p><strong>list.jsp</strong></p>

<pre><code>&lt;table&gt;
&lt;c:forEach items="${arraylist}" var="key"&gt;
            &lt;tr&gt;
               &lt;td&gt;${key.email_id}&lt;/td&gt;
               &lt;td&gt;${key.pwd}&lt;/td&gt; 
            &lt;/c:forEach&gt;
&lt;/table&gt;
</code></pre>