Learn Java for Web Development

(Tina Meador) #1
CHAPTER 5: Building Java Web Applications with Spring Web MVC 255

author1.setAuthorName("Vishal Layka");
Book book1 = new Book();
book1.setBookId((long) 1);
book1.setBookTitle("Beginning Groovy, Grails and Griffon");
book1.setAuthor(author1);


Book book2 = new Book();
book2.setBookId((long) 2);
book2.setBookTitle("Modern Java Web Development");
book2.setAuthor(author1);


bookList = new LinkedList();
bookList.add(book1);
bookList.add(book2);
}


public List getBookList() {
return bookList;
}


public Book createBook(Book b) {
Book book = new Book();
book.setBookId((long)bookList.size() + 1);
book.setAuthor(b.getAuthor());
book.setBookTitle(b.getBookTitle());
bookList.add(book);
return book;
}


}


Listing 5-48 illustrates the modified bookList.jsp of the bookstore application for form processing.


Listing 5-48. bookList.jsp



  1. <%@page contentType="text/html" pageEncoding="UTF-8"%>

  2. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

  3. <!DOCTYPE html>











  4. Your Book store








  5. Books List





















  6. Author Book Title