title: How to fetch data from dynamically generated JSP page in Struts 2?
body: <p>I am generating below page using Struts2. It is generating properly.</p>
  
  <p>My question is how fetch the value from generated page when I click on <code>delete</code> button so I can further process for delete data from database and regenerate page with remaining data?</p>
  
  <pre class="lang-jsp prettyprint-override"><code>  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
   &lt;%@ taglib uri="/struts-tags" prefix="s" %&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;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h3&gt;All Records:&lt;/h3&gt;
          &lt;table&gt;  
          &lt;s:form action="upload"&gt; 
          &lt;s:iterator   value="list"&gt; 
          &lt;tr&gt;
          &lt;td &gt;&lt;s:property value="id"/&gt;&lt;/td&gt; 
          &lt;td &gt;&lt;s:property value="name"/&gt;&lt;/td&gt;  
          &lt;td&gt;&lt;s:property value="password"/&gt;&lt;/td&gt;  
          &lt;td&gt;&lt;s:property value="email"/&gt;&lt;/td&gt; 
          &lt;td&gt;&lt;s:property  value="gender"/&gt;&lt;/td&gt;
          &lt;td&gt;&lt;s:checkbox  name="checked" label="isChecked"  theme="simple" /&gt;&lt;/td&gt;       
          &lt;/tr&gt;    
          &lt;/s:iterator&gt; 
          &lt;s:submit value="delete" name="delete" /&gt;
          &lt;/s:form&gt;
          &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>RegisterAction.java</p>
  
  <pre><code>package com.javatpoint;
  
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  import java.util.ArrayList;
  
  public class RegisterAction {
  private String name,password,email,gender,country;
  int id;
  
  public int getId() {
      return id;
  }
  
  public void setId(int id) {
      this.id = id;
  }
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public String getPassword() {
      return password;
  }
  
  public void setPassword(String password) {
      this.password = password;
  }
  
  public String getEmail() {
      return email;
  }
  
  public void setEmail(String email) {
      this.email = email;
  }
  
  public String getGender() {
      return gender;
  }
  
  public void setGender(String gender) {
      this.gender = gender;
  }
  
  public String getCountry() {
      return country;
  }
  
  public void setCountry(String country) {
      this.country = country;
  }
  
  ArrayList&lt;User&gt; list=new ArrayList&lt;User&gt;();  
  
  public ArrayList&lt;User&gt; getList() {  
      return list;  
  }  
  public void setList(ArrayList&lt;User&gt; list) {  
      this.list = list;  
  }  
  
  public String execute(){
      int i=RegisterDao.save(this);
      if(i&gt;0){
          Connection con=RegisterDao.con;
          try {
               PreparedStatement ps=con.prepareStatement("select * from STRUTSUSER");
               ResultSet rs=ps.executeQuery();  
          //  rs = ps.getGeneratedKeys();
                while(rs.next()){  
                 User user=new User();  
                 user.setId(rs.getInt(1));
  
                 user.setName(rs.getString(1));  
                 user.setPassword(rs.getString(2));  
                 user.setEmail(rs.getString(3)); 
                 user.setGender(rs.getString(4));
                 list.add(user);  
                // System.out.println("yo");
                }  
  
                con.close();  
          } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }  
      return "success";
      }
      return "error";
  }
  </code></pre>