File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt in Custom Tag Question ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in Custom Tag Question !" Watch "Doubt in Custom Tag Question !" New topic
Author

Doubt in Custom Tag Question !

Jagjit Dhaliwal
Greenhorn

Joined: Aug 19, 2007
Posts: 20
Can anyone help me in understanding answer for following question which I got it from one of mock exam:

Consider the following usage of a custom tag in a JSP page:

<jsp:useBean id="student" scope = "session" class="com.xyz.Student" />
<mytaglib:studentTag student='student' />
Which of the following statements are correct?
Select 1 correct option.
A.Application objects such as com.xyz.Student, cannot be passed as attributes to custom tags.
B.The Student object will be passed to the studentTag tag handler.
C.The Student object will NOT be passed because no variable named student is defined.
D.A Student object will not be created if it is not available it the session.
E.None of these.


Jagjit Dhaliwal<br />SCJP 1.4(90%),SCWCD 1.4(86%)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I'd say E.
A : anything can be passed to custom tags
B : No, a String will be passed. It should be student="${student}" instead.
C : a student variable is defined by useBean
D : with this useBean syntax, a bean will be created if not found.


[My Blog]
All roads lead to JavaRanch
Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
<jsp:useBean id="student" scope = "session" class="com.xyz.Student" />
<mytaglib:studentTag student='student' />
Which of the following statements are correct?
Select 1 correct option.
A.Application objects such as com.xyz.Student, cannot be passed as attributes to custom tags.
B.The Student object will be passed to the studentTag tag handler.
C.The Student object will NOT be passed because no variable named student is defined.
D.A Student object will not be created if it is not available it the session.
E.None of these.


A) is Incorrect - Objects can be passed as attributes to custom tags
B) is Incorrect - You are just passing String 'student' to custom tag and
not the student object.
C) is Incorrect - There is a student object but you are not passing it.
D) is Incorrect - As you have provided class attribtue, a new object
will be created in it doesn;t exists.
E) This is correct
Jagjit Dhaliwal
Greenhorn

Joined: Aug 19, 2007
Posts: 20
Thanks Christophe & Sandeep !!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in Custom Tag Question !