Hey,
Nun möchte ich eine Action schreiben die eine ActionForm nutz und auf einer JSP die Categories in einer SELECTBOX (Cateory name) ausgibt. Was muss ich tun?
Danke schonmal!
Java:
public class CategoryDTO implements Serializable {
private String id;
private String name;
private String description;
private String picture;
public CategoryDTO(ResultSet rs) {
try {
id = rs.getString("categoryid");
name = rs.getString("name");
description = rs.getString("description");
picture = rs.getString("imageurl");
} catch (SQLException e) {
e.printStackTrace();
}
}
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public void setPicture(String picture) {
this.picture = picture;
}
public String getPicture() {
return picture;
}
}
Java:
public class CategoryDB {
public static Collection<CategoryDTO> findAll(Connection con) {
List<CategoryDTO> li = new ArrayList<CategoryDTO>();
if(con != null) {
try {
PreparedStatement ps = con.prepareStatement(
"select * from category");
ResultSet rs = ps.executeQuery();
while(rs.next() == true) {
li.add(new CategoryDTO(rs));
}
rs.close();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
} else
throw new IllegalArgumentException();
return li;
}
}
Nun möchte ich eine Action schreiben die eine ActionForm nutz und auf einer JSP die Categories in einer SELECTBOX (Cateory name) ausgibt. Was muss ich tun?
Danke schonmal!