labs / tiddlers / content / labs / lab07 / _Labs_07_Displaying the

The easiest way to make the filter buttons on the page work is to use links via <a> tags. Using forms makes the styling harder since a form is a block element that will fill the width of the container which means that we can only have one button per row if with use forms. Links are inline elements, so we can have many buttons per row of we use <a> tags instead of forms. We can nest <button> tags in the <a> tags so that the links look like button.

We can use query parameters (which are appended to the end of the URL) to pass simple parameters to a page without needing to use sessions. We are going to pass the category as a query parameter to the view-students.jsp page. The URL will look like:


Display the majors above the table in the view-students.jsp page using a for-loop scriptlet:

<a href="view-students.jsp?major=All"><button>All</button></a>

    Collection<String> majors = dao.getMajors();

    for (String major : majors) {
    <a href="view-students.jsp?major=<%= major %>"><button><%= major %></button></a>