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:
[code]
<%@page import="mypackagenamehere.*"%>
<html>
<body>
<%
out.println(new AddressBook().addressRows.toString());
%>
</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?
Wojtek - 09 Dec 2007 23:56 GMT
francan00@yahoo.com wrote :
> 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)
[quoted text clipped - 46 lines]
> Please advise how I can get this to work without JSTL in my Tomcat
> 4.1.3 container?
maybe: new AddressBook().addressRows().toString()
Note the two brackets after addressRows.

Signature
Wojtek :-)
Arne Vajhøj - 10 Dec 2007 00:38 GMT
> 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:
> AddressBook addressBook = new AddressBook();
> List addressRows = addressBook.getAllAddresses();
> request.setAttribute("addressRows", addressRows);
> request.getRequestDispatcher("/WEB-INF/webpage/
> view.jsp").forward(request, response);
> <%@page import="mypackagenamehere.*"%>
> <html>
[quoted text clipped - 10 lines]
> Generated servlet error:
> addressRows cannot be resolved or is not a field
Try:
<%
List addressRows = (List)request.getAttribute("addressRows");
for(int i = 0; i < addressRows.size(); i++) {
X row = (X)addresRows.get(i);
out.println(row.getFirstname());
out.println(row.getLastname());
}
%>
Arne