On the jsp page; I have a logic:iterate tag which loops through data from an xml file and displays it within a drop down. How do i take and store the selected option from the drop down into the form-bean for processing.

<html:select name="BookForm" property="book" multiple="true">

<bean:define name="BookForm" property="BookList" id="bklist" />
<html:options collection="bklist" property="bookId" labelProperty="bookName" />
</html:select>

public class Book{
int  bookId;
String bookName;


public int getBookId() {
    return medId;
}

public void setBookId(int bookId) {
    this.bookId = bookId;
}

public String getBookName() {
    return bookName;
}

public void setBookName(String bookName) {
    this. bookName =  bookName;
}

}
public class BookForm {
private List bookList;
private String[] book;
public void setBookList(List medList){
    this.bookList = bookList;
}

public List getBookList(){
    return this.bookList;
}

public String[] getBook() {
    return book;
}

public void setBook(String[] book) {
    this.book = book;
}

}
 public static List getBooks(){
    PreparedStatement pStmt = null;
 Connection con = null;
 boolean success = false;
 ResultSet rs = null;
 List bookList = new ArrayList();

 try{
     conn = getConnection();

     String sql = " select * from BOOK ";
     pStmt = conn.prepareStatement(sql);

     rs = pStmt.executeQuery();
     while(rs.next()){
         Book book= new Book();
         book.setBookId(rs.getInt("Book_ID"));
         book.setBookName(rs.getString("Book_NAME"));
         bookList.add(book);
         }               
 }catch(Exception e){
     e.printStackTrace();

 }finally{
     closeConnectionProp(conn,pStmt,rs);
 }        
 return bookList;    
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.