This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL vs. JSP implicit objects

 
Srinu Nanduri
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • 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?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
My question is "How is C correct?"
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not correct
 
Srinu Nanduri
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
The answer is only "A".
 
Amol Fuke
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srinu ,

Just to confirm ,

Is empId the object of EmployeeId ?

Thanks,
Amol
 
Jan Sterk
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Got it..

Thanks,
Amol
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic