I have a problem that is very similar to this stack overflow question JSP not finding property in bean. And also this question javax.el.PropertyNotFoundException: Property 'foo' not found on type com.example.Bean. However in my case I think that i have done everything by the books and I am still getting an error. Below is part of my javabean code snippet
private double otheramount;
private int no;
private String name;
public double getOtherAmount()
{
return otheramount;
}
public void setOtherAmount(double newotheramount)
{
otheramount = newotheramount;
}
public int getNo()
{
return no;
}
public void setNo(int newno)
{
no = newno;
}
public String getName()
{
return name;
}
public void setName(String newname)
{
name = newname;
}
Below is part of my DAO code
while(rs.next())
{
MyBean mybean = new MyBean();
mybean.setNo(rs.getInt("No"));
mybean.setName(rs.getString("Full_Names"));
mybean.setOtherAmount(rs.getDouble("OtherAmount"));
allresults.add(mybean);
}
Below is part of the servlet code
try
{
ArrayList allresults = mydao.search();
request.setAttribute("allresults",allresults);
RequestDispatcher dispatch =request.getRequestDispatcher("Pages/mypage.jsp");
dispatch.forward(request, response);
}
catch(Exception ex)
{
}
Below is my HTML and JSTL code in the JSP page
<c:forEach var="results" items="${requestScope.allresults}">
<tr>
<td><c:out value="${results.no}"></c:out></td>
<td><c:out value="${results.name}"></c:out></td>
<td><c:out value="${results.otheramount}"></c:out></td>
</tr>
</c:forEach>
The problem is that when I comment the part <c:out value="${results.otheramount}"></c:out>
it runs okay and no errors are thrown. However uncommenting this part results in the error of property not found.
As a side note, the property otheramount was added much later.
I am using Netbeans 7.1.2. Any help greatly appreciated.