index.jsp:
...
<form action="showSchool" method="get">
<input type="submit" value="Login">
``</form>
...
Servlet:
@WebServlet(urlPatterns = "/showSchool")
public class Servlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
School school = Model.getInstance().school;
req.setAttribute("school", school);
RequestDispatcher requestDispatcher = req.getRequestDispatcher("showSchool.jsp");
requestDispatcher.forward(req, resp);
}
}
showSchool.jsp:
...
<jsp:useBean id="school" class="model.School" scope="request"></jsp:useBean>
...
<tbody>
<%for(Classroom classroom: school.getClassroom()){ %>
<tr>
<td><%=classroom.getClassId()%></td>
<td><%=classroom.getClassname()%></td>
<td>
<form action="showStudent" method="get">
<input type="hidden" id = "student" name="student" value="<%=classroom.getClassId()%>">
<input type = submit value="Schueler der Klasse">
</form>
</td>
</tr>
<% } %>
<tr>
<td>
<form action="addClass" method="get">
<input type="hidden" id = "school" name="school" value="<%=school%>">
<input type = submit value="Klasse hinzufuegen">
</form>
</td>
</tr>
</tbody>
...