I have a page that prints out a record using an object that comes from a servlet. I dont have JSTL (due to restrictions in my environment) and need to show the JSP view without JSTL:
Here is the servlet part:
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
AddressBook addressBook = new AddressBook();
List addressRows = addressBook.getAllAddresses();
request.setAttribute("addressRows", addressRows);
request.getRequestDispatcher("/WEB-INF/webpage/view.jsp").forward(request, response);
}
JSP that works with JSTL
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<body>
<c:forEach var="row" items="${addressRows}">
${row.firstname}
${row.lastname}
</c:forEach>
</body>
</html>
Now my attempt to show the record without JSTL:
<%@page import="mypackagenamehere.*"%>
<html>
<body>
<%
out.println("Data: " + new AddressBook().addressRows.toString() + " - record info.");
%>
</body>
</html>
This gives me an error:
An error occurred at line: 29 in the jsp file: /WEB-INF/webpage/view.jsp
Generated servlet error:
addressRows cannot be resolved or is not a field
Please advise how I can get this to work without JSTL in my Tomcat 4.1.3 container?