5

I have a code as following:

FriendsList = new ArrayList()
....   
ResultSet rs = st.executeQuery(Select);
while (rs.next()) {
   Member member = new Member(rs);
   FriendsList.add(member);
}

it successfully get the results and goes to constructor of Member class and add data to it. but once I try to access one of its properties using FriendsList property from my jsp file I run into following error:

 "Caused by: javax.el.PropertyNotFoundException: Property 'Name' not found on type   
 application.Member"

Using Eclipse I have generated a completed list of setters and getters for every property of Member class as following:

    public String getName() {
    return Name;
}
public void setName(String name) {
    Name = name;
}
Eme Emertana
  • 561
  • 8
  • 14
  • 29
  • 2
    The answer is correct, you should be using `"name"`, not `"Name"`, in your JSP. But why would you ask a question about your JSP without showing the part of the JSP that causes the error? – Dave Newton Sep 15 '12 at 13:25

1 Answers1

10

The key is the conversion of "property name" to the method name. In general the getter name is obtained by taking the property name, uppercasing the first character and prepending "get".

So if you want to call the getName method the property is "name" with a lowercase n, not an uppercase N.

There are also many many special cases for properties that actually do start with uppercase letters and the like, but life is much simpler if you set it up so your property names always start with lower case letters.

EdC
  • 2,309
  • 1
  • 17
  • 30
  • 1
    your advise of "but life is much simpler if you set it up so your property names always start with lower case letters." really made my life easier :) – Vinod May 23 '16 at 06:36