labs / tiddlers / content / labs / lab04 / _Labs_04_Viewing

The view-students.jsp page is where we are going to display all of the students that have been saved in the session.

  1. Delete the two lines of code that were added to the <main> tag earlier in the lab.

  2. Add the following code the the <main> tag:

                 Collection<Student> students = (Collection<Student>) session.getAttribute("studentList");
                 if (students != null) {
                     for (Student student : students) {
                     <td><%= student.getId() %></td>
                     <td><%= student.getName() %></td>
                     <td><%= student.getAddress() %></td>
     <a class="nav" href="index.html">Back to Menu</a>

    This code is creating an HTML table. It gets the students list out of the session and loops through each student in the list. The loop will cause the <tr> (table row) tag to be repeated for as many students as there are in the list. The <td> tags contain expressions that will add the student's details to the table.

  3. Build and redeploy the web application.

  4. The system should now be functionally complete. Try adding a couple of students and then viewing them.