• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Doubt in Custom Tag Question !

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christophe & Sandeep !!
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic