About Question enthuware.jwpv6.2.1020 :

Moderator: admin

Post Reply
ETS User

About Question enthuware.jwpv6.2.1020 :

Post by ETS User »

Why is this correct ?

${map[map["2"]]}

Isn't this a map of a map ?

Guest

Re: About Question enthuware.jwpv6.2.1020 :

Post by Guest »

map["2"] returns "3" and this result is used as argument for the second map call. And this will return 4.

chibee1620

Re: About Question enthuware.jwpv6.2.1020 :

Post by chibee1620 »

When do you have to put quotes around the contents of [] in el?
whats the difference between ${map[map[2]]} and ${map[map["2"]]}?

Vimal

Re: About Question enthuware.jwpv6.2.1020 :

Post by Vimal »

Yeah..
whats the difference between ${map[map[2]]} and ${map[map["2"]]}?

Anybody to help>..

admin
Site Admin
Posts: 10066
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1020 :

Post by admin »

Please go through Section 1.6 of Expression Language Specification 2.2, which explains this very clearly.
The EL follows ECMAScript in unifying the treatment of the . and [] operators.
expr-a.identifier-b is equivalent to expr-a["identifier-b"]; that is, the
identifier identifier-b is used to construct a literal whose value is the identifier,
and then the [] operator is used with that value.
Similarly, expr-a.identifier-b(params)is equivalent to expra["
identifier-b"](params).
If you like our products and services, please help us by posting your review here.

dhanuddhara
Posts: 12
Joined: Fri Aug 15, 2014 10:16 am
Contact:

Re: About Question enthuware.jwpv6.2.1020 :

Post by dhanuddhara »

Could someone explain me, why option 3 is wrong?
when considering question on 'enthuware.jwpv6.2.1019' it also should be a correct answer.

admin
Site Admin
Posts: 10066
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1020 :

Post by admin »

3 is not a valid identifier. It is an integer and is interpreted as an index. That is why map.o is ok (as is the case in 2.1019) but map.3 is not.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

shareef.hiasat
Posts: 20
Joined: Thu Dec 19, 2013 8:22 am
Contact:

Re: About Question enthuware.jwpv6.2.1020 :

Post by shareef.hiasat »

admin wrote:Please go through Section 1.6 of Expression Language Specification 2.2, which explains this very clearly.
The EL follows ECMAScript in unifying the treatment of the . and [] operators.
expr-a.identifier-b is equivalent to expr-a["identifier-b"]; that is, the
identifier identifier-b is used to construct a literal whose value is the identifier,
and then the [] operator is used with that value.
Similarly, expr-a.identifier-b(params)is equivalent to expra["
identifier-b"](params).
sorry but am not convinced can you put it in simpler words thanks
any reference example on internet would be good thanks

and why the question has no explanation ! it is categorized as tought right!

admin
Site Admin
Posts: 10066
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1020 :

Post by admin »

Sure, can you tell me with which part exactly do you have trouble understanding?
For examples, you can try writing short jsp programs and run it under tomcat.
-Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 153 guests