aspose file tools*
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
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: EL - [ ] and .