java - error populating a table using jstl -
i getting following error when trying populate table in view.jsp using jstl access list of objects stored in request object of viewservlet:
/web-inf/jsp/admin/view.jsp (line: 34, column: 16) attribute value invalid tag foreach according tld
can show me how fix code populate table correctly without error?
here relevant parts of view.jsp:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <table> <!-- here should go titles... --> <tr> <th>type</th> <th>number</th> <th>id</th> </tr> <c:foreach begin="1" end= "${ no }" step="1" varstatus="loopcounter" value="${coursesummaries}" var="coursesummary"> <tr> <td> <c:out value="${coursesummary.coursetype}" /> </td> <td> <c:out value="${coursesummary.numunits}" /> </td> <td> <c:out value="${coursesummary.id}" /> </td> </tr> </c:foreach> </table>
here relevant parts of viewservlet.java:
protected void doget(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception { string idstring = req.getparameter("id"); long id = new long(idstring); list<coursesummary> coursesummaries = new coursesummarydao().findall(id); req.setattribute("coursesummaries", coursesummaries); jsp.forward(req, resp); }
and here entire stack trace:
org.apache.jasper.jasperexception: /web-inf/jsp/admin/view.jsp (line: 34, column: 16) attribute value invalid tag foreach according tld org.apache.jasper.compiler.defaulterrorhandler.jsperror(defaulterrorhandler.java:42) org.apache.jasper.compiler.errordispatcher.dispatch(errordispatcher.java:443) org.apache.jasper.compiler.errordispatcher.jsperror(errordispatcher.java:237) org.apache.jasper.compiler.validator$validatevisitor.checkxmlattributes(validator.java:1265) org.apache.jasper.compiler.validator$validatevisitor.visit(validator.java:875) org.apache.jasper.compiler.node$customtag.accept(node.java:1539) org.apache.jasper.compiler.node$nodes.visit(node.java:2376) org.apache.jasper.compiler.node$visitor.visitbody(node.java:2428) org.apache.jasper.compiler.node$visitor.visit(node.java:2434) org.apache.jasper.compiler.node$root.accept(node.java:475) org.apache.jasper.compiler.node$nodes.visit(node.java:2376) org.apache.jasper.compiler.validator.validateexdirectives(validator.java:1798) org.apache.jasper.compiler.compiler.generatejava(compiler.java:217) org.apache.jasper.compiler.compiler.compile(compiler.java:373) org.apache.jasper.compiler.compiler.compile(compiler.java:353) org.apache.jasper.compiler.compiler.compile(compiler.java:340) org.apache.jasper.jspcompilationcontext.compile(jspcompilationcontext.java:646) org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:357) org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:390) org.apache.jasper.servlet.jspservlet.service(jspservlet.java:334) javax.servlet.http.httpservlet.service(httpservlet.java:728) myapp.viewservlet.doget(viewschoolservlet.java:39) javax.servlet.http.httpservlet.service(httpservlet.java:621) javax.servlet.http.httpservlet.service(httpservlet.java:728) myapp.securityfilter.dofilter(securityfilter.java:56)
you trying use value
attribute, not valid attribute <c:foreach>
tag. perhaps meant use items
:
<c:foreach begin="1" end= "${ no }" step="1" varstatus="loopcounter" items="${coursesummaries}" var="coursesummary">
see <c:foreach>
oracle doc list of valid attributes.
apart that, don't understand intent of using begin
, end
, , step
, attribute, given iterating on collection. aren't using them. , don't need them imho.
Comments
Post a Comment