wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Error in HFSJ question regarding EL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Error in HFSJ question regarding EL?" Watch "Error in HFSJ question regarding EL?" New topic
Author

Error in HFSJ question regarding EL?

Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
On page 484, question 7, a code snippet that uses scriplets has to be rewritten using custom tags and EL.

snippet of snippet:

Answer B is the right answer according to the book:


If I'm not mistaken, beerService has to be an instance variable, that is declared somewhere else in the page with the <%! scripting element. It is not an attribute, otherwise beerService.getStyles() throws an exception.

But if isn't an attribute, and it certainly isn't an implicit EL object, then ${beerService.styles} will not work! The identifier left to the first dot in an EL expression has to be either an attribute, or an implicit EL object..

[ June 23, 2008: Message edited by: Jan Sterk ]

[ June 23, 2008: Message edited by: Jan Sterk ]
[ June 23, 2008: Message edited by: Jan Sterk ]

SCJP 1.4 (81%)<br />SCWCD 5 (95%)
S Sravs
Ranch Hand

Joined: Feb 25, 2008
Posts: 85
The question is about the beerService.getStyles();
just remember and assume when ever you encounter "set" and "get" then there is bean class behind the scenes.
when any bean is instantiated in the current page the default scope is page.
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
That is not the point. The thing is, if "beerService" is an attribute, the code should be like

(BeerService)(application.getAttribute("beerService")).getStyles()

If it is an instance variable, then the EL thing will not work.
[ June 24, 2008: Message edited by: Jan Sterk ]
Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
I believe Jan is correct. I did not review the spec, but if we can believe the book regarding EL, then beerService is a reference to an attribute. For the snipped to work the reference would have to have been initialized before the snippit.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I don't have the full question, but the above snipets are obviously missing something.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in HFSJ question regarding EL?