title: retrieve updated array list from jsp to action class in struts2
body: <p>I am retrieving database values and putting them in an array list(al). This array list is getting displayed in a JSP page in the form of a table. I want to modify the values in JSP page and update the new value in the database using Struts2. How do i do that?</p>
  
  <p>Main action class</p>
  
  <pre><code>public class HelloWorldAction extends ActionSupport implements SessionAware{
  ProjectDb pd;
  public ProjectDb getPd() {
      return pd;
  }
  
  public void setPd(ProjectDb pd) {
      this.pd = pd;
  }
  ArrayList&lt;ProjectDb&gt; al=new ArrayList&lt;ProjectDb&gt;();
  public ArrayList&lt;ProjectDb&gt; getAl() {
  
      return al;
  }
  
  public String status() throws Exception{
      boolean flag=false;
  
  
      try{
          Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
  
          Connection conn = DriverManager
                  .getConnection("jdbc:ucanaccess://D:\\Db1.mdb");
  
          username=(String) map.get("user");
          PreparedStatement ps=conn.prepareStatement(  
                  "SELECT * FROM StaleInGers WHERE (((StaleInGers.mailId)=(Select email from DBA where username='"+username+"' and email='"+email+"')))");  
          //ps.setString(1,username);  
          //ps.setString(2,password);  
  
          ResultSet rs=ps.executeQuery();  
  
          al=new ArrayList&lt;ProjectDb&gt;();
          while(rs.next()){
              pd =new ProjectDb();
              pd.setProject(rs.getString("project"));
              pd.setStatus(rs.getString("status"));
              pd.setComments(rs.getString("comments")); 
  
              al.add(pd);
  
  
              flag=true;
          }
  
  
      } catch (Exception e) {
          System.out.println("Exception : " +e);
      }  
      if(flag==true){
          return "success";
      }
      else{
          return "error";
      }       
     }
  }
  </code></pre>
  
  <p>This is POJO class</p>
  
  <pre><code>public class ProjectDb {
  private String project,status,comments,email;
  
  public String getEmail() {
  return email;
  }
  
  public void setEmail(String email) {
  this.email = email;
   }
  
  public String getProject() {
  return project;
  }
  
  public void setProject(String project) {
  this.project = project;
  }
  
  public String getStatus() {
  return status;
  }
  
  public void setStatus(String status) {
  this.status = status;
  }
  
  public String getComments() {
  return comments;
  }
  
  public void setComments(String comments) {
  this.comments = comments;
  }
  }
  </code></pre>
  
  <p>This is the JSP page where i display the array list</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="s" uri="/struts-tags" %&gt; 
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4 
  /loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;style type="text/css"&gt;
  table,td,th {
  border: 1px solid green;
  width:100%;
  }
  
  th {
  background-color: green;
  color: white;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="update"&gt;
  &lt;table &gt;
  &lt;tr&gt;
  &lt;th&gt;Project&lt;/th&gt;
  &lt;th&gt;Status&lt;/th&gt;
  &lt;th&gt;Comments&lt;/th&gt;
  &lt;/tr&gt;
  &lt;s:iterator value="al" id="array" status="alStatus"&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;s:property value="%{project}"/&gt;&lt;/td&gt; 
  &lt;td&gt;&lt;s:textfield name="array[%{#alStatus.index}].status" value="%{status}" theme="simple" 
  /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;s:textfield name="array[%{#alStatus.index}].comments" value="%{comments}" theme="simple" 
  /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;/s:iterator&gt;
      &lt;/table&gt;&lt;br&gt;&lt;br&gt;
      &lt;input style="opacity: 0.7; border-radius: 5px; border: 0; width: 250px;   
         height:35px;          
         font-family: Goudy Old Style; font-size: 22px; background: #00CC80;"
         type="submit" value="Submit"&gt;
      &lt;/form&gt;             
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>