You can’t do ${foo.1}

With beans and Maps, you can use the dot operator, but only if the thing you type after the dot is a legal Java identifer.

This

${musicMap.Ambient}

Note

works

Is the same as this1

${musicMap["Ambient"]}

Note

works

But this

${musicList["1"]}

CANNOT be turned into this

${musicList.1}

Note

NO! NO! NO!

Note

If you wouldn’t use it for a variable name in your Java code, DON’T put it after the dot.

Servlet code

foo.Person p = new foo.Person();
p.setName("Leelu");
foo.Dog d = new foo.Dog();
d.setName("Clyde");
foo.Toy t1 = new foo.Toy();
t1.setName("stick");
foo.Toy t2 = new foo.Toy();
t2.setName("neighbor's cat");
foo.Toy t3 = new foo.Toy();
t3.setName("Barbie™ doll head");
d.setToys(new foo.Toy[]{t1, t2, t3});
p.setDog(d);
request.setAttribute("person", p);

Compose the EL for this output:

image with no caption
image with no caption
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset