0

I have a facultylist.jsp page which displays List<Faculty> as a request attribute parameter in forEach loop and I want every item in this loop to be a link to specified faculty facultyview.jsp. How can I achieve that ?

facultylist.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Faculties</title>
</head>
<body>
<h1>Faculties list</h1>
    <ul>
        <c:forEach var="faculty" items="${faculties}">
            <li><a href="???">${faculty.name}</a></li>
        </c:forEach>
    </ul>
</body>
</html>

facultyview.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Faculty</title>
</head>
<body>
    <h1>${faculty.name}</h1>
    <ul>
        <li>Faculty name: <c:out value="${requestScope.name}"></c:out></li>
        <li>Total seats: <c:out value="${requestScope.total_seats}"></c:out></li>
        <li>Budget seats: <c:out value="${requestScope.budget_seats}"></c:out></li>
    </ul>
    <a href="faculty?apply">apply for this faculty </a>
</body>
</html>

I don't know if its may help, but I'm using following technologies: tomcat, jsp, servlets and log4j.In my project I have one FrontController, which is a servlet that interacts with Command pattern - each Command returns a path to resource and action type: forward or redirect.

marknorkin
  • 3,904
  • 10
  • 46
  • 82
  • @JordiCastilla faculty represents an entity from database, i'm not sure if I want to change it adding another field, or you mean some other way ? – marknorkin Jan 20 '15 at 09:11
  • @Jango but `${faculty.url}` means that I have a field in faculty, which is not true – marknorkin Jan 20 '15 at 09:12
  • check my answer's edit, but since i'm not sure how you get the URL's, I can't help more... – Jordi Castilla Jan 20 '15 at 09:17