• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Enthuware question doubt on EL

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic