For example, let's implement the list categories functionality in index.jsp
. Our index page will list the available categories. For that, it accesses the bookshelf service instance that was stored in the session.
<%@ page import="java.util.Set"%> <%@ include file="init.inc.jsp" %> <html> <head> <title>Bookshelf - Browse Categories</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> </head> <body> <%@ include file="menu.inc.jsp" %> <h2>Bookshelf - Browse Categories</h2> <% Set<String> categories = sessionBean.getBookshelf().getCategories( sessionBean.getSessionId()); %><ul> <% for (String category : categories) { %> <li> <a href="http://byCategory.jsp?category=<%= category %>"> <%=category%></a> </li> <% } %></ul> </body> </html>
Each entry in the list links to the byCategory.jsp
page, which takes a category
as a parameter and lists the books in that category.
The menu.inc.jsp
file is a menu table with links to the available operations. It is not listed here.