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 Exmulator mock exam question 66 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 "Exmulator mock exam question 66" Watch "Exmulator mock exam question 66" New topic
Author

Exmulator mock exam question 66

PRavi kumar
Ranch Hand

Joined: May 13, 2007
Posts: 69
66
Marks: 1 Given a JSP page that contains the following code

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<jsp:useBean class="com.examulator.userBean" id="user" />And given that userBean has a correctly defined setFirstName

Which of the following will set the firstName property of the userBean instance?

a)
<c:set target="${user}" property="firstName" value="marcus"/>

b)
<c:set property="firstName" var="user" value="elephant"/>

c)
<c:set target="user" property="firstName" value="marcus"/>

d)
<c:set id="user" property="firstName" value="marcus"/>

e)
<c:set id="user" target="firstName" value="marcus"/>

I thinks thre is no answer is for this question. but the mock exam shows answer is A.

can any one expalin how A is the answer for this question.

according to c:set rules "The target value of c:set must be eveluate to the actual bean object "
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Ravi,

I didn't get what doubt you have in your mind.

It looks high way for me. please state you query correctly.

it was given that UserBean is coorectly configured for to setFirstName.


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

The target value of c:set must be eveluate to the actual bean object

Then why do you think that ${user} is not the actual bean ?


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I've got two comments :
1. class="com.examulator.userBean" should be class="com.examulator.UserBean"
2. I'd be better to use <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> (JSTL 1.1)

If you don't mind, could you please try to contact the author about that ? Thank you.
PRavi kumar
Ranch Hand

Joined: May 13, 2007
Posts: 69
Hi,
Thanks a lot for replay


<jsp:useBean class="com.examulator.userBean" id="user" />
in above statement the "user" is the ID of the UseBean

a)
<c:set target="${user}" property="firstName" value="marcus"/>

the same id (user) is using as a target="${user}". this is refering to the ID of the bean not to the actual object.

may be I understand the the question wrongly.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

No, "user" is referring to the id, but "${user}" is referring to the real bean.
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
I recommend writing the code and testing the code. Create the userBean class and directory etc etc. It's an excellent way to learn. You can check if the value has been set with the following JSTL code.

<c ut value="${user.firstName}"/>


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
PRavi kumar
Ranch Hand

Joined: May 13, 2007
Posts: 69
Thanks a lot Marcus.
 
wood burning stoves
 
subject: Exmulator mock exam question 66
 
Similar Threads
jsp:useBean
New summary exam
Help: Wrox Profession SCWCD - don't understand
JSTL Question -Marcus Green
taglib uri cannot be resolved