title: How display data fetched from database on a jsp page in dropdown list using struts2 with mysql
body: <p>How display data fetched from database on a JSP in drop down list using struts?  I have done the code for the drop-down list using array list for the city but error has occurred.</p>
  
  <pre><code>HTTP Status 500 - type Exception report message description 
  The server encountered an internal error () that prevented it from fulfilling this request.   
  exception org.apache.jasper.JasperException: tag 'select', field 'list', name 
    'location': The requested list key '%{city}' could not be resolved 
     as a collection/array/map/enumeration/iterator type.
  </code></pre>
  
  <p>I have done this code for the city list are as follows:</p>
  
  <p>JAVA code</p>
  
  <pre><code> public class Event extends ActionSupport{
  
   private String description;
   public List&lt;String&gt; city;
   public List&lt;String&gt; getCity() {
   return city;
   }
   public void setCity(List&lt;String&gt; city) {
   this.city = city;
   }   
   public String execute() throws Exception{
  
   String url = "jdbc:mysql://localhost:20976";  
   String dbName = "chetan";  
   String driverName = "com.mysql.jdbc.Driver";  
   String user = "root";
   String pass = "root121";
   Connection con = null;  
   Statement stmt = null;  
   ResultSet rs = null;  
   try {  
      Class.forName(driverName).newInstance();  
      con = DriverManager.getConnection(url + dbName, user,pass);  
      stmt = con.createStatement();  
   } catch (Exception e) {  
      System.out.println(e.getMessage());  
   }  
  
   rs = stmt.executeQuery("select * from City");  
   while (rs.next()) {  
      city.add(rs.getString("Location"));  
  
  
   }  
  
   return SUCCESS;  
  
   }
  </code></pre>
  
  <p>JSP CODE for the City</p>
  
  <pre><code> &lt;s:select name="location" label="Location" headerValue="Select City" list="city" /&gt;
   &lt;s:submit value="Submit" method="execute" key="submit" align="center" /&gt;
  </code></pre>