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?
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".
<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.
Still a bad question because I feel that 3. and 4. are equally correct