This document contains 10 sample questions about dynamic attributes in JavaServer Pages (JSP). Dynamic attributes allow JSP tags to accept arbitrary attributes that are not defined in the tag's Tag Library Descriptor (TLD). The questions cover how to configure dynamic attributes for different tag types (tag files, simple tags, classic tags) and what code is required to access dynamic attributes from within a tag.
1 of 22
Download to read offline
More Related Content
10 sample questions about Dynamic Attributes (CX-310-083)
2. Tems of useTems of use
2
You may use this document for your own purpose only if you leave the document as is.
? Copyright 2010 Prolector.
For more information please visit http://www.prolector.nl
You may use this document for your own purpose only if you leave the document as is.
? Copyright 2010 Prolector.
For more information please visit http://www.prolector.nl
3. Question 1:Question 1:
3
Dynamic Attributes can be applied in:
ServletsA
JSPB
Tag FileC
Classic TagD
Modern TagE
Simple TagF
Every class that implements javax.servlet.jsp.tagext.JspTagG
4. Question 1:Question 1:
4
Dynamic Attributes can be applied in:
ServletsA
JSPB
Tag FileC
Classic TagD
Modern TagE
Simple TagF
Every class that implements javax.servlet.jsp.tagext.JspTagG
5. Question 2:Question 2:
5
In order to have dynamic attribues working for a tag file you need to do the following:
implement the interface javax.servlet.jsp.tags.DynamicAttributesA
you must add dynamic-attributes to the tag directiveB
implement the interface javax.servlet.jsp.tagext.DynamicAttributesC
Add <dynamic-attributes>true</dynamic-attributes> in the tldD
You must configure the tld in the web.xml in jsp-config sectionE
6. Question 2:Question 2:
6
In order to have dynamic attribues working for a tag file you need to do the following:
implement the interface javax.servlet.jsp.tags.DynamicAttributesA
you must add dynamic-attributes to the tag directiveB
implement the interface javax.servlet.jsp.tagext.DynamicAttributesC
Add <dynamic-attributes>true</dynamic-attributes> in the tldD
You must configure the tld in the web.xml in jsp-config sectionE
9. Question 4:Question 4:
9
Choose the correct directive for a tag file that should use dynamic attributes:
<%@ tag body-content="empty" dynamic-attributes="dynamicAttributes" %>A
<%@ tag body-content="empty" dynamic-attribute="dynamicAttributes" %>B
<%@tag body-content="empty" dynamic-attributes="variables" %>C
<%@tag body-content="empty" dynamic-attribute="variables" %>D
10. Question 4:Question 4:
10
Choose the correct directive for a tag file that should use dynamic attributes:
<%@ tag body-content="empty" dynamic-attributes="dynamicAttributes" %>A
<%@ tag body-content="empty" dynamic-attribute="dynamicAttributes" %>B
<%@tag body-content="empty" dynamic-attributes="variables" %>C
<%@tag body-content="empty" dynamic-attribute="variables" %>D
11. Question 5:Question 5:
11
If an tag is declared in a tld, which xml child element of tag should be placed to enable
dynamic properties:
<auto-attributes>true</auto-attributes>A
<auto-wire>true</auto-wire>B
<dynamic-attributes>true</dynamic-attributes>C
<dynamic-attribute>true</dynamic-attribute>D
<dynamic-properties>true</dynamic-properties>E
12. Question 5:Question 5:
12
If an tag is declared in a tld, which xml child element of tag should be placed to enable
dynamic properties:
<auto-attributes>true</auto-attributes>A
<auto-wire>true</auto-wire>B
<dynamic-attributes>true</dynamic-attributes>C
<dynamic-attribute>true</dynamic-attribute>D
<dynamic-properties>true</dynamic-properties>E
13. Question 6:Question 6:
13
Given the following tag code:
<%@ tag body-content="empty" dynamic-attributes="dynatrs" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<table>
<c:forEach items="${dynattrs}" var="element">
<tr>
<td>${element.key}</td>
<td>${element.value}</td>
</tr>
</c:forEach>
</table>
what will the result be for <myTags:demo myAttribute="een waarde"/> ?
<table><tr><td>myAttribute</td><td>een waarde</td></tr></table>A
<table><tr><td>een waarde</td><td>myAttribute</td></tr></table>B
<table><tr><td></td><td></td></tr></table>C
<table></table>D
An exception will be throw at runtimeE
None of the aboveF
14. Question 6:Question 6:
14
Given the following tag code:
<%@ tag body-content="empty" dynamic-attributes="dynatrs" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<table>
<c:forEach items="${dynattrs}" var="element">
<tr>
<td>${element.key}</td>
<td>${element.value}</td>
</tr>
</c:forEach>
</table>
what will the result be for <myTags:demo myAttribute="een waarde"/> ?
<table><tr><td>myAttribute</td><td>een waarde</td></tr></table>A
<table><tr><td>een waarde</td><td>myAttribute</td></tr></table>B
<table><tr><td></td><td></td></tr></table>C
<table></table>D
An exception will be throw at runtimeE
None of the aboveF
15. Question 7:Question 7:
15
Given the following tag code:
<%@ tag body-content="empty" dynamic-attributes="dynattrs" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<table>
<c:forEach items="${dynattrs}" var="element">
<tr>
<td>${element.key}</td>
<td>${element.value}</td>
</tr>
</c:forEach>
</table>
what will the result be for <myTags:demo myAttribute="een waarde"/> ?
<table><tr><td>myAttribute</td><td>een waarde</td></tr></table>A
<table><tr><td>een waarde</td><td>myAttribute</td></tr></table>B
<table><tr><td></td><td></td></tr></table>C
<table></table>D
An exception will be throw at runtimeE
None of the aboveF
16. Question 7:Question 7:
16
Given the following tag code:
<%@ tag body-content="empty" dynamic-attributes="dynattrs" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<table>
<c:forEach items="${dynattrs}" var="element">
<tr>
<td>${element.key}</td>
<td>${element.value}</td>
</tr>
</c:forEach>
</table>
what will the result be for <myTags:demo myAttribute="een waarde"/> ?
<table><tr><td>myAttribute</td><td>een waarde</td></tr></table>A
<table><tr><td>een waarde</td><td>myAttribute</td></tr></table>B
<table><tr><td></td><td></td></tr></table>C
<table></table>D
An exception will be throw at runtimeE
None of the aboveF
17. Question 8:Question 8:
17
In order to have dynamic attributes working for a simple tag you need to do the
following:
implement the interface javax.servlet.jsp.tagext.DynamicAttributesA
you must add dynamic-attributes to the tag directiveB
implement the interface javax.servlet.jsp.tags.DynamicAttributesC
Add <dynamic-attributes>true</dynamic-attributes> in the tldD
You must configure the tld in the web.xml in jsp-config sectionE
18. Question 8:Question 8:
18
In order to have dynamic attributes working for a simple tag you need to do the
following:
implement the interface javax.servlet.jsp.tagext.DynamicAttributesA
you must add dynamic-attributes to the tag directiveB
implement the interface javax.servlet.jsp.tags.DynamicAttributesC
Add <dynamic-attributes>true</dynamic-attributes> in the tldD
You must configure the tld in the web.xml in jsp-config sectionE
19. Question 9:Question 9:
19
In order to have dynamic attributes working for a classic tag you need to do the
following:
implement the interface javax.servlet.jsp.tags.DynamicAttributesA
you must add dynamic-attributes to the tag directiveB
implement the interface javax.servlet.jsp.tagext.DynamicAttributesC
Add <dynamic-attributes>true</dynamic-attributes> in the tldD
You must configure the tld in the web.xml in jsp-config sectionE
20. Question 9:Question 9:
20
In order to have dynamic attributes working for a classic tag you need to do the
following:
implement the interface javax.servlet.jsp.tags.DynamicAttributesA
you must add dynamic-attributes to the tag directiveB
implement the interface javax.servlet.jsp.tagext.DynamicAttributesC
Add <dynamic-attributes>true</dynamic-attributes> in the tldD
You must configure the tld in the web.xml in jsp-config sectionE
21. Question 10:Question 10:
21
Given a simple tag that has configured in the tld only one attribute 'name' and has
support for dynamic attributes. Given the following snippet how many time will the
method setDynamicAttribute be invoked?
<myTags:dynamicSimpleTag myAttribute="een waarde" enNogEenAttribute="enz..."
name="name"/>
0A
1B
2C
3D
4E
22. Question 10:Question 10:
22
Given a simple tag that has configured in the tld only one attribute 'name' and has
support for dynamic attributes. Given the following snippet how many time will the
method setDynamicAttribute be invoked?
<myTags:dynamicSimpleTag myAttribute="een waarde" enNogEenAttribute="enz..."
name="name"/>
0A
1B
2C
3D
4E