Thursday, April 28, 2011

Self Test: Chapters 44 & 45

Questions

Question 1:

Which three of the following is part of the Tag Library Descriptor element?
A. namespace
B. name
C. tag handler class
D. tag attributes

Question 2:

Which two of the following attributes are not part of the taglib directive?
A. url
B. uri
C. prefix
D. name

Question 3:

Which file does the following DTD element definition apply to: ?
A. web.init
B. YourTagHandler.java
C. YourTagLibraryDefinition.tld
D. web.xml

Question 4:

Which of the following is the Web Deployment Descriptor, the purpose of which is to configure a Web application?
A. web.xml
B. web.init
C. YourTagLibraryDefinition.tld
D. YourTagHandler.java

Question 5:

Which three of the following files is part of a simple tag library?
A. web.xml
B. web.init
C. YourTagLibraryDefinition.tld
D. YourTagHandler.java

Question 6:

How do you declare a tag library within a JSP page?
A. You use a declare scriptlet.
B. You use a taglib directive.
C. You use a unique variable.
D. You use the path to the tag handler.

Question 7:

Which two of the following options apply to an empty custom tag?
A. Specified in the web.xml Web component descriptor.
B. Specified in the tag library handler.
C. < libraryPrefix : handlerName / >
D. A custom tag with no body.

Question 8:

What does the container use to validate a custom tag in a JSP page?
A. web.xml
B. Xerces
C. Xmlspy
D. Tag Library Descriptor

Question 9:

Which interface does the doStartTag() belong to?
A. TagSupport
B. TagProcess
C. Tag
D. TagStart

Question 10:

What does the container do during translation when it encounters a custom tag in a JSP page?
A. It converts the XML notation into Java calls, inserted into the Java that resulted from the page translation.
B. It passes it to the tag handler.
C. It converts it to scriptlets.
D. It adds the code to the output stream.

Answers:

Question 1:

B, C, and D. All of these are part of the Tag Library Descriptor element except option A. Also, you need a JSP file such as yourJSP.jsp.

Question 2:

A and D. The taglib directive only takes two attributes, uri and prefix.

Question 3:

D. The taglib element is used to describe a JSP tag library. The syntax for the taglib element in the web.xml file is < ! ELEMENT taglib (taglib-uri, taglib-location) >. The required taglib-location element contains the location and the taglib-uri element describes a URI identifying a Tag Library used in the Web application. You use the URI to give a tag library a unique address or namespace.

Question 4:

A. The web.xml file is used as the deployment descriptor. The deployment descriptor defines the elements and configuration information of a Web application. In it you define elements to support the Web application within a servlet container, including ServletContext init parameters, session configuration, and servlet declarations..”
Note: We will be covering Deployment & Deployment Descriptions shortly. So for now, just know this about the web.xml file.

Question 5:

A, C, and D. All of these files could be used as part of your tag library except option B because web.init is not a file defined by the specification. Also, you need a JSP file such as yourJSP.jsp.

Question 6:

B. The taglib directive creates a reference to the prefix. The prefix tells the container which library you want. Once that is done, you can use a custom tag, so called because it is your tag, not a standard one that came shipped with the container.

Question 7:

C and D. C uses correct XML notation to refer to an empty tag. By convention, we call a custom tag in a JSP page without a body an empty custom tag.

Question 8:

D. The Tag Library Descriptor (TLD) is used by a Web container to validate the tags in a JSP page.

Question 9:

A. Your tag handler is a class that extends the TagSupport abstract class if it has doStartTag() and doEndTag() methods.

Question 10:

A. The container will combine the JSP code and tag library into one Java source file. The container converts your custom tags into Java calls during the JSP page translation.

Previous Chapter: Quick Recap - Chapters 44 & 45

Next chapter: chapter 46 - JSP API

No comments:

Post a Comment

© 2013 by www.inheritingjava.blogspot.com. All rights reserved. No part of this blog or its contents may be reproduced or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior written permission of the Author.

ShareThis

Google+ Followers

Followers