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

HFSJ EL-Functions mock question doubt

 
Adam Czysciak
Ranch Hand
Posts: 90
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I'm going through HFSJ... Page 431, question 14, on EL functions:

JSP:
1. <@ taglib uri="/WEB-INF/myfuncts" prefix="my" %?
2. <%- insert code here -->

Which, inserted at line 2 in the JSP, is a valid EL function invocation
A. $(repeat(2, "420")}
B. $(repeat("2", "420")}
C. $(my:repeat(2, "420")}
D. $(my:repeat("2", "420")}
E. A valid invocation CANNOT be determined

The correct answer is E with explanation "Option E is correct. The necessary mapping information is NOT known."

My question is - why is it not know? If we assume that there exists a proper .tld file, then isn't C the correct invocation? Of course A and B are incorrect, as "my" prefix is required.

And what about D? Aren't EL functions arguments coerced the way they do in EL expressions?
 
Reshma Shanbhag
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to implement this example, the app throws with the following exception ..






I am not sure if am doing anything wrong ... the class is definition is a..




and the TLD declaration is as follows ..





and the jsp invocation with the taglib directive included in the page is:






Why is the Servlet container looking for a int class ... rather than considering it as a primitive ??? when i execute this example without the method parameter it works fine .. am i doing anything wrong ???




Reshma
 
Reshma Shanbhag
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got the answer to my post ...


The function signature in the TLD must only have type's in parameter list and not the variable identifiers .. that was the mistake !!

it must be


and not




Coming to the Orignal Post..

If the proper TLD was in place option C & D (arguments are coerced) would have been correct options.

In book option E is selected, as there is no mention (no TLD) of the name "repeat" is to be used to invoke the tag. So as the TLD in not available we cannot determine valid invocation, hence E is the right option from the given Choices.


Hope this helps,

Reshma
 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question is - why is it not know? If we assume that there exists a proper .tld file, then isn't C the correct invocation? Of course A and B are incorrect, as "my" prefix is required.


Actually, it is the fact that the question does not specify the TLD for this EL function, that makes Option E the only valid option.

Remember that a certification question must be self-contained. You are not allowed to make any assumptions; unless the question itself tells you to assume something.

Does that make sense?

Cheers,
Bryan
 
Reshma Shanbhag
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for clarifying Bryan ... that makes it very clear
 
Adam Czysciak
Ranch Hand
Posts: 90
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bryan. That explains everything. So it is just like I though - I need to read the questions carefully and not to assume anything
[ May 25, 2006: Message edited by: Adam Czysciak ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic