File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL - [ ] and ." Watch "EL - [ ] and ." New topic

EL - [ ] and .

saps rao

Joined: May 21, 2007
Posts: 6

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 ${[0].name}.

Below are the classes (relavant part).

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

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

public class Toy{
private String name;
public void setName(String 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?

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

[My Blog]
All roads lead to JavaRanch
I agree. Here's the link:
subject: EL - [ ] and .
jQuery in Action, 3rd edition