Which is true about TLD files?
(JSP v2.0 pgs 3-16, 1-160)
A. | TLD files may be placed in any subdirectory of | |
B. | TLD files are used to configure JSP environment attributes, such as | |
C. | TLD files may be placed in the | |
D. | TLD files can declare both Simple and Classic tags, but TLD files are NOT used to declare Tag Files. |
Assuming the standard JSTL prefix conventions are used, which JSTL tags would you use to iterate over a collection of objects? (Choose all that apply.)
(JSTL v1.1 pg. 42)
A JSP page contains a taglib
directive whose uri
attribute has the value myTags
. Which deployment descriptor element defines the associated TLD?
(JSP v2.0 pgs 3-12,13)
A. | <taglib> <uri>myTags</uri> <location>/WEB-INF/myTags.tld</location> </taglib> | |
B. | <taglib> <uri>myTags</uri> <tld-location>/WEB-INF/myTags.tld</tld-location> </taglib> | |
C. | <taglib> <tld-uri>myTags</tld-uri> <tld-location>/WEB-INF/myTags.tld</tld-location> </taglib> | |
D. | <taglib> <taglib-uri>myTags</taglib-uri> <taglib-location>/WEB-INF/myTags.tld</taglib-location> </taglib> |
A JavaBean Person
has a property called address
. The value of this property is another JavaBean Address
with the following string properties: street1
, street2
, city
, stateCode
and zipCode
. A controller servlet creates a session-scoped attribute called customer
that is an instance of the Person
bean.
(JSTL v1.1 pg 4-28)
Which JSP code structures will set the city
property of the customer
attribute to the city
request parameter? (Choose all that apply.)
A. | ${sessionScope.customer.address.city = param.city} | |
B. | <c:set target="${sessionScope.customer.address}" property="city" value="${param.city}" /> | |
C. | <c:set scope="session" var="${customer.address}" property="city" value="${param.city}" /> | |
D. | <c:set target="${sessionScope.customer.address}" property="city"> ${param.city} </c:set> |
Which <body-content>
element combinations in the TLD are valid for the following JSP snippet? (Choose all that apply.)
(JSP v2.0 Appendix JSP.C specifically pgs 3-21 and 3-30)
11. <my:tag1> 12. <my:tag2 a="47" /> 13. <% a = 420; %> 14. <my:tag3> 15. value = ${a} 16. </my:tag3> 17. </my:tag1>
A. | tag1 body-content is tag2 body-content is tag3 body-content is | |
B. | tag1 body-content is tag2 body-content is tag3 body-content is | |
C. | tag1 body-content is tag2 body-content is tag3 body-content is | |
D. | tag1 body-content is tag2 body-content is tag3 body-content is | |
E. | tag1 body-content is tag2 body-content is tag3 body-content is |
-Tag1 includes scripting code so it must have at least ‘JSP’ body-content. Tag2 is only shown as an empty tag, but it could also contain ‘JSP’ or ‘scriptless’ body-content. Tag3 contains no scripting code so it may have either ‘JSP’ or ‘scriptless’ body-content.
-Option A is invalid because tag1 cannot be ‘empty’.
-Option D is invalid because tag1 cannot be ‘scriptless’.
Assuming the appropriate taglib
directives, which are valid examples of custom tag usage? (Choose all that apply.)
(JSP v2.0 section 7)
A. |
| |
B. |
| |
C. |
| |
D. |
| |
E. |
|
Given the following scriptlet code:
(JSTL v1.1 pg 6-48)
11. <select name='styleId'> 12. <% BeerStyle[] styles = beerService.getStyles(); 13. for ( int i=0; i < styles.length; i++ ) { 14. BeerStyle style = styles[i]; %> 15. <option value='<%= style.getObjectID() %>'> 16. <%= style.getTitle() %> 17. </option> 18. <% } %> 19. </select>
Which JSTL code snippet produces the same result?
A. | <select name='styleId'> <c:for array='${beerService.styles}'> <option value='${item.objectID}'>${item.title}</option> </c:for> </select> | |
B. | <select name='styleId'> <c:forEach var='style' items='${beerService.styles}'> <option value='${style.objectID}'>${style.title}</option> </c:forEach> </select> | |
C. | <select name='styleId'> <c:for var='style' array='${beerService.styles}'> <option value='${style.objectID}'>${style.title}</option> </c:for> </select> | |
D. | <select name='styleId'> <c:forEach var='style' array='${beerService.styles}'> <option value='${style.objectID}'>${style.title}</option> </c:for> </select> |