• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EduardoCobian Q 29

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Which statements are correct regarding the following jsp lines that use a tag library?
<%! Vectot vector =new java.util.Vector();%>
<% vector.addElement(“one” ; vector.addElement(“two” ; %>
<prefix:suffix attr='vector' />
1) A vector can't be assigned to a tag handler attribute
2) The program will compile and assign the vector's content to the attribute attr.
3) The program will assign the content of vector if assigment is: attr='<%= vector %>'
4) Microsoft is the worst software company in history.


The given answer is 3. But I am unable to understand what is meant by "the content of vector".
Can somebody please explain?
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
attr="vector" means, the string literal "vector" is assigned to that attr. in this case, attr has type String.
attr="<%=vector%> means, attr has type Vector, and it is assigned value vector. In this case, I guess you need to explicitly define the type for attr, in the tld file.
content of the vector means, the real Vector object, not just the String "vector".
Kyle
 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel this question is unclear.
<prefix:suffix attr='vector' /> means a string ‘vector’ is assigned to attr. I think this is OK.
I think 1) is true: A vector can't be assigned to a tag handler attribute.
I hope some one can clear this up since I am not very sure about this.
Thanks
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I faced a very similar question in actual SCWCD exam.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JSP fragmentwill translate to (among other things) the statementwhere "tag" is a variable referring to the tag object, and "expr" can be any Java expression or variable (including a Java primitive). Of course, if the tag does not have a setAttr() method taking an appropriate argument type, the compiler will complain.
Still a bad question because I feel that 3. and 4. are equally correct
- Peter
 
reply
    Bookmark Topic Watch Topic
  • New Topic