Question

I am new to Java web application. I have been using a tutorial to learn Java. I am stuck when trying to use jstl tag. I have a category table with two fields, i.e. "Name" and "id". Name of the category and name of the image file I use are the same. Here is the source code. When I try to run the application it shows the following error:

HTTP Status 500 - Internal Server Error

type Exception report

messageInternal Server Error

description
    The server encountered an internal error that prevented it from fulfilling this request.

exception
    org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'id'.

root cause
    javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'id'.

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.
GlassFish Server Open Source Edition 4.0 

I have added javax.servlet.jsp.jstl-api-1.2.1-javadoc.jar and jstl-impl-1.2.jar file in lib folder under WEB-INF folder. But still I encounter the above problem. Could anyone help me out with this.

Here is my code of index.jsp. I have deployed application in glassfish server 4.0

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%-- 
    Document   : index
    Created on : Feb 18, 2014, 1:18:40 PM
    Author     : sabin
--%>

<sql:query var="categories" dataSource="jdbc/affablebean">
    SELECT * FROM category
</sql:query>

<div id="indexLeftColumn">
    <div id="welcomeText">
        <p>[ welcome text ]</p>
        categoryImagePath:${initParam.categoryImagePath}
        productImagePath:${initParam.productImagePath}
    </div>
</div>

<div id="indexRightColumn">
    <c:forEach var="category" items="$(categories.rows}">
        <div class="categoryBox">
            <a href="category?${category.id}">
                <span class="categoryLabelText">${category.name}</span>
                <img src="${initParam.categoryImagePath}${category.name}.jpg" alt="${category.name}">
            </a>
        </div>
    </c:forEach>
</div>
Was it helpful?

Solution

You have a typo: $( instead of a ${. Change this line

<c:forEach var="category" items="$(categories.rows}">

to

<c:forEach var="category" items="${categories.rows}">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top