Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Properties vs. Attributes

 
Ken Duncan
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a difficult time with EL implicit objects. How do I know when something is an attribute and when it is a property? To me, those mean the same thing, but clearly they are not used the same way in this context. For example, I guess if I want to know something about a request object, I use requestScope. If I want to access a request parameter, I use request. I tried to figure out what is in a RequestScope, but the API doc I found was virtually useless at http://java.sun.com/j2ee/1.4/docs/api/:
REQUEST_SCOPE

public static final int REQUEST_SCOPE

Request scope: the named reference remains available from the ServletRequest associated with the Servlet until the current request is completed.

See Also:
Constant Field Values

So how can I find out what attributes there are in a RequestScope? Thanks.

Ken
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming this really should be Parameters vs Attributes, as that's the common point of confusion.

An attribute can be retrieved via a scope implicit object like requestScope OR if the first variable in an EL statement doesn't match an implicit object it will look for it as an attribute in the scopes for you. An attribute can be any type of Object and is set by the developer

A parameter is a String value that gets submitted with the user's request. You'd use the param EL implicit object to access these.
 
Ken Duncan
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marc Peabody:
I'm assuming this really should be Parameters vs Attributes, as that's the common point of confusion.

An attribute can be retrieved via a scope implicit object like requestScope OR if the first variable in an EL statement doesn't match an implicit object it will look for it as an attribute in the scopes for you. An attribute can be any type of Object and is set by the developer

A parameter is a String value that gets submitted with the user's request. You'd use the param EL implicit object to access these.


I'm looking at P. 385 in HFSJ and it distinguishes attributes and properties, so I'm not, I guess, on the "saem page."

Ken
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The example shows:

${foo.person.name}

This EL assumes there is an attribute with the key of foo. Remember attributes can be any type of Object.

This example assumes that the object returned has a getPerson() method. The getPerson() method should return some other object which has a getName() method.

The concept of "property" is not specific to web programming. You should have seen this term numerous times while studying for SCJP.



In the above code, which is a very simple JavaBean called MyClass, the class has a property called myThing.
[ February 06, 2008: Message edited by: Marc Peabody ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic