Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enthuware question doubt on EL

 
Felix Li
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rufus Addis
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Felix Li
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rufus Addis
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Praveen Kumar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some doubts on Enthuware mock exams...
I'll ask them in another thread.
[ October 16, 2008: Message edited by: Christophe Verre ]
 
Rufus Addis
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Praveen, if you have questions, keep the discussion at the ranch, and ask them in your own thread. Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic