Expression Language

I have a question about the expression language (EL). In my jsp, why does ${book.name} work but ${book.Name} does not? It seems they would both be interpreted as to call book.getName(). Any insights? Thanks.

example

//java entity class

publicclass Book{

private String name;

}

public String getName(){

return this.name;

}

publicvoid setName(String name){

this.name=name;

}

//jsp

<jsp:useBean id="book" type="com.library.book" scope="session"/>

Book name: ${book.name}

Book name: ${book.Name}//throws error

[1280 byte] By [Greg439a] at [2007-11-27 6:44:04]
# 1

You've just got to turn it around a little bit.

It doesn't actually go looking for a method matching the property you are looking up, it goes looking for a property exposed by the bean. If you haven't defined a BeanInfo class, then it uses introspection to access java bean properties in the standard manner.

The getName() method exposes the property "name". It does not expose the property "Name". Thus why it can find ${book.name} but not ${book.Name}

Agreed both "name" and "Name" properties would convert to getName() via the capitalization rules. However the method getName() converts to "name" only. And also by convention properties should all start with lower case letters.

evnafetsa at 2007-7-12 18:15:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...