Forums Register Login

Enthuware question doubt on EL

+Pie Number of slices to send: Send
com.enthuware.ets.scwcd.v5.2.564

I have confusion on this question regarding EL.

Given:

<%
Map m = new HashMap();
m.put("m", "n");
m.put("n", "o");
m.put("o", "p");
pageContext.setAttribute("map", m, PageContext.PAGE_SCOPE);
%>

Which of the following will output p?

One of the option I chose was ${map[map[n]]} and the explaination says that it will work if it is ${map[map["n"]]}, how come?

Thanks in advance.
+Pie Number of slices to send: Send
If the "n" is not in quotes, then it assumes that n is the name of a bound attribute, and substitutes the value of that attribute, (or in your case blank if there is no attribute of that name).

If you had in your scriptlet included the line:

pageContext.setAttribute("n", "o", PageContext.PAGE_SCOPE);

then a bare n should have worked.

I would strongly recommend you have a good play with EL and make sure you thoroughly understand all combinations of [] notation with respect to maps and arrays as it WILL crop up in the exam.

Rufus.
+Pie Number of slices to send: Send
Thanks Rufus.

Yeah I heard from the forum that EL takes a big part. Unfortunately enthuware and head first don't have too many practices on them. So I will have to explore more on the internet.

Thanks.
+Pie Number of slices to send: Send
You don't need to read that much up about it. Once you have the basic knowledge all you need to do is spend a couple of evenings with a text editor and Tomcat trying things out.

There's only so many combinations of quotes, no quotes, square brackets, missing / null values with maps, arrays and java beans to try out.

Rufus.
+Pie Number of slices to send: Send
I have some doubts on Enthuware mock exams...
I'll ask them in another thread.
[ October 16, 2008: Message edited by: Christophe Verre ]
+Pie Number of slices to send: Send
@Praveen you do realise that with Enthuware you get full online support. So if you do have any doubts or questions about their mock(s) you can raise them via their website.

In the past I've found them very responsive!

HTH - Rufus.
+Pie Number of slices to send: Send
Praveen, if you have questions, keep the discussion at the ranch, and ask them in your own thread. Thank you.
Paper beats rock. Scissors beats tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 613 times.
Similar Threads
Bug in a kathy sierra prog...
Using object as keys in maps
Enthuware 1ZO-894 question - confused
mock question regarding EL
working of map?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:50:04.