• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL accessing bean properties

 
Yasir Bajwa
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Very new to web development/Java and reading HFSJ, on chapter 8 right now

The . operator is for accessing beans or maps (correct?), but at one point it is used as

pageContext.request.method

pageContext is a bean, but I don't think the request object is? It has method (removeAttribute) that is not a getter/setter

Is the requirement that the property just has a getProperty method, or does the object have to be a java bean.
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The . operator can be used to access Bean-like properties (accessors) on any object (it need not conform entirely to the JavaBean spec.). So the example you quote is equivalent to the raw Java syntax:

pageContext.getRequest().getMethod()

The name before the first . is the variable name of the object, while all subsequent names are either properties (where "method" is intepreted as "getMethod()" or "isMethod()" whichever exists), or must be keys for entries in a map.

So in summary:
Is the requirement that the property just has a getProperty method, or does the object have to be a java bean.
The first statement is correct: the object need only have a getProperty method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic