This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL - [ ] and . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL - [ ] and ." Watch "EL - [ ] and ." New topic
Author

EL - [ ] and .

saps rao
Greenhorn

Joined: May 21, 2007
Posts: 6
Hello,

As per the HFSJ book, the [ ] operator can be used anywhere in the place of the . operator.
In the code magnets exercise in page 379-380 (in HFSJ), the person's dog's toy's name is accessed using ${person.dog.toys[0].name}.

Below are the classes (relavant part).

public class Person
{
private Dog dog;
public void setDog(Dog dog){
this.dog = dog;
}
public Dog getDog(){
return dog;
}
}

public class Dog
{
private Toy[] toys;
public void setToys(String[] toys){
this.toys = toys;
}
public Toy[] getToys{
return toys;
}
}

public class Toy{
private String name;
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
}

And a an attribute named "person" is set using a servlet and forwarded to a jsp.

If I want to access the dog's toy's name using only [ ] operator, how can I do that?

thanks,
swapna.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16



[My Blog]
All roads lead to JavaRanch
 
wood burning stoves
 
subject: EL - [ ] and .
 
Similar Threads
El property not found problem
HFSJ page 380
Using pageContext in EL
EL Execution Problem
Not working with 1.5