I am getting an error in JSP and I cannot figure out what is causing it. I have included all of the appropriate libraries and I’ve made sure to follow bean convention on uppercase/lowercase. Here’s the relevant code in the JSP:
<c:forEach items="${relevantData}" var="entry">
<p>${entry.price}</p>
</c:forEach>
The relevantData was a List<MyData>. For the purposes of this question it is sufficent to say MyData is a class that contains a Double named price (with a Getter and Setter following the bean convention). When I try to load this page I receive the following error in the server logs (Tomcat 7.0.22):
javax.el.PropertyNotFoundException:
Property 'price' not readable on type java.lang.Double
Why am I getting this error and how do I fix it?
The problem was actually caused by the visibility of the
MyDataclass. I had auto-generated theMyDataclass in Netbeans but I did not notice that there was no keywordpublicin front of the class name. This meant that by the time it got to the JSP there was no way for it to read the properties inMyData.I changed the type to
publicand the problem was solved.