This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Confused about HFSJ Final Mock Exam Question 63 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Confused about HFSJ Final Mock Exam Question 63" Watch "Confused about HFSJ Final Mock Exam Question 63" New topic
Author

Confused about HFSJ Final Mock Exam Question 63

Tarun Yadav
Ranch Hand

Joined: Sep 20, 2007
Posts: 134
This is Question 63 from the Head First Servlet and JSP final mock exam, appendix A.

1. <%@ taglib uri="http://www.mycompany.com/mytags" prefix="mytags" %>

2. <mytags:foo bar="abc" />
3. <mytags:forEach><mytagsoSomething /></mytags:forEach>
4. <jsp:setProperty name="x" property="a" value="b" />
5. <cut value="hello" />

Assuming this is a complete JSP, which is true?

(For options E and F, ignore the fact that an error in one line might keep a subsequent line from being reached)

A. Only line 2 will definitely generate an error
B. Only line 3 will definitely generate an error
C. Only line 4 will definitely generate an error
D. Only line 5 will definitely generate an error
E. Lines 4 and 5 will both definitely generate errors
F. Lines 2, 3, 4 and 5 will all definitely generate errors
G. The entire JSP could execute without generating any errors

Handwritten notes:
- Options A and B are incorrect because, assuming the tags used are appropriately defined in the mytags tag library, there is nothing wrong with them

- Option C is incorrect because this is a valid JSP standard action. The jsp prefix does not need to be referenced in a taglib directive

- Option D is correct because there is no taglib directive shown for the prefix c.

As I understand it, <jsp:useBean> creates a local variable in the _jspService() method with the name as specified in the 'id' attribute. So, as I see it, the <jsp:setProperty> in this code should also cause an exception because there is no <jsp:useBean> action anywhere.

Am I missing something here or is this actually wrong?
[ October 08, 2007: Message edited by: Tarun Yadav ]
Bert Meijers
Greenhorn

Joined: Feb 06, 2011
Posts: 15
Hi Tarun,

Finally, after 3,5 year somebody posts a reply at your message.

I have the same question!!

In my opinion, there first should be bean instantiated, for example bij using "jsp:useBean".
In the meantime, did you find any answer to your question?

I will come back juli 2014 to see if there is an answer

Greetz
Bert
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1646
    
  25

Hi Bert,
In my opinion, there first should be bean instantiated, for example bij using "jsp:useBean".

Yes, you are right, a bean should be instantiated (however not necessarily by a jsp:useBean action). The answer to the question is wrong!

David Bridgewater in his book states:
1. The setProperty/getProperty can be used on a bean not defined in a <jsp:useBean>. If the bean is available in the page scope. (but if it isn't there it will result in an error 500) However it is not recommended to do so.

And the JSP2.0 specs say:
JSP.5.2 <jsp:setProperty>
name
The name of a bean instance defined by a <jsp:useBean> action or some other action. The bean instance must contain the property to be set. The defining action must appear before the <jsp:setProperty> action in the same file.

Regards,
Frits
Bert Meijers
Greenhorn

Joined: Feb 06, 2011
Posts: 15
Hi Frits,

Thanks for your reply. It gets sometimes confusing, sorting out the answers.
I find Javaranch often to the rescue, a good place to look for brothers-in-arms,
just like now, where somebody else, a couple of years ago, struggled the same issue.
Or to find friendly advice from a rancher.

Greetz
Bert
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confused about HFSJ Final Mock Exam Question 63
 
Similar Threads
Q 63 from SCWCD mock exam
HFSJ final mock exam question 63
mock exam questions 54 and 61
Error in the final mock exam Qn 63?
JSP question shared