• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Properties vs. Attributes

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic