• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

EL vs. JSP implicit objects

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assume that the JSP implicit objects cannot be accessed in EL and that is why we have dedicated EL implicit objects.

However, the following question from javabeat

18) Assume that a property by name 'eId' is defined in the EmployeeId object,
which inturn is contained in Employee class by the name 'empId'.
<% EmployeeId id = new EmployeeId(1000); %>
<% Employee employee = new Employee(id); %>
<% request.setAttribute("johny", employee); %>
which of the following uses the correct EL for accessing the eId property?
a. ${requestScope.johny.empId.eId}
b. ${requestScope.johny.eId.empId}
c. ${request.johny.empId.eId}
d. ${requestScope[johny"[empId[eId]]]}
e. All the above.

has the answer

18) a, c and e.
Options a, c and e are correct.

How are these correct?
 
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

<% request.setAttribute("johny", employee); %>


Everything put into the request will be available via EL's requestScope implicit object. Even if you set an attribute from a scriptlet into the request, you can read it back from EL. The requestScope is a Map containing all request scoped attributes.
 
Srinu Nanduri
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My question is "How is C correct?"
 
Christophe Verré
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
It's not correct
 
Srinu Nanduri
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Srinu,

Could you please give me what is the answer for this question?

Thanks & Regards,
Sudhakar Karnati
[ June 20, 2008: Message edited by: sudhakar karnati ]
 
Srinu Nanduri
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer is only "A".
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Srinu ,

Just to confirm ,

Is empId the object of EmployeeId ?

Thanks,
Amol
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amol,

Johnny is an Employee object. Employee has a property empId, which returns an EmployeeId object. EmployeeId has a property eId.
 
Amol Fuke
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it..

Thanks,
Amol
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic