File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Properties vs. Attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Properties vs. Attributes" Watch "Properties vs. Attributes" New topic
Author

Properties vs. Attributes

Ken Duncan
Ranch Hand

Joined: Apr 30, 2007
Posts: 42
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

Joined: Feb 05, 2003
Posts: 4727

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.


A good workman is known by his tools.
Ken Duncan
Ranch Hand

Joined: Apr 30, 2007
Posts: 42
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

Joined: Feb 05, 2003
Posts: 4727

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 ]
 
 
subject: Properties vs. Attributes
 
Similar Threads
PageContext and servletContext
how to use HttpServletRequest to get an Application scope variable ?
Implicit objects in jsp
servlets
how to overwrite a request param?