PREV NEXT
Java Taglibrary Questions:
1.When implementing a tag, if the tag just includes the body verbatim, or if it does not include the body, then the tag handler class must extend the BodyTagSupport class. Is this statement true of false.
2. Fill in the blanks. A tag handler class must implement the javax.servlet.jsp.tagext.Tag interface. This is accomplished by extending the class TagSupport or another class named in one of the options below. Select the one correct answer.
- IterationTag
- TagClass
- BodyTag
- BodyTagSupport
3. Is this statement true or false. The deployment descriptor of a web application must have the name web.xml . In the same way the tag library descriptor file must be called taglib.xml .
4. A JSP file that uses a tag library must declare the tag library first. The tag library is defined using the taglib directive – <%= taglib uri=”…” prefix=”…”%>
Which of the following specifies the correct purpose of prefix attribute. Select the one correct answer.
- The prefix defines the name of the tag that may be used for a tag library.
- The prefix attribute defines the location of the tag library descriptor file.
- The prefix attribute should refer to the short name attribute of the tag library file that is defined by the uri attribute of taglib directive.
- The prefix attribute is used in front of a tagname of a tag defined within the tag library.
5. A JSP file uses a tag as <myTaglib:myTag>. The myTag element here should be defined in the tag library descriptor file in the tag element using which element. Select the one correct answer.
A. tagname
B. name
C. tag
D. prefix
6. Which of the elements defined within the taglib element of taglib descriptor file are required. Select the two correct answers.
A. tlib-version
B. short-name
C. uri
D. display-name
7. Which of the elements defined within the taglib element of taglib descriptor file are required. Select the two correct answers.
A. name
B. description
C. validator
D. tag-class
E. display-name
8. Name the element within the tag element that defines the name of the class that implements the functionality of tag. Select the one correct answer.
- class-name
- tag
- class
- tag-class
- tei-class
9. Which of these are legal return types of the doStartTag method defined in a class that extends TagSupport class. Select the two correct answers.
A. EVAL_PAGE
B. EVAL_BODY
C. EVAL_PAGE_INCLUDE
D. EVAL_BODY_INCLUDE
E. SKIP_PAGE
F. SKIP_BODY
G. SKIP_PAGE_INCLUDE
H. SKIP_BODY_INCLUDE
10. Which of these are legal return types of the doAfterBody method defined in a class that extends TagSupport< class. Select the two correct answers.
A. EVAL_PAGE
B. EVAL_BODY
C. EVAL_PAGE_AGAIN
D. EVAL_BODY_AGAIN
E. SKIP_PAGE
F. SKIP_BODY
G. SKIP_PAGE_AGAIN
H. SKIP_BODY_AGAIN
11. Which of these are legal return types of the doEndTag method defined in a class that extends TagSupport class. Select the two correct answers.
A. EVAL_PAGE
B. EVAL_BODY
C. EVAL_PAGE_INCLUDE
D. EVAL_BODY_INCLUDE
E. SKIP_PAGE
F. SKIP_BODY
G. SKIP_PAGE_INCLUDE
H. SKIP_BODY_INCLUDE
Answers to questions on tag library
- false. Such a class should extend the TagSupport class.
- D. BodyTagSupport extends TagSupport and implements interfaces Tag and IterationTag.
- false. The tag library descriptor file can have any name. It need not have the name taglib.xml .
- d. If the taglib directive directive defines a prefix of test, and a tag is called myTag, then the tag is used as <test:myTag>.
- b. The name element inside the tag element defines the tag name to which the prefix of the taglib is attached. For example <name> myTag </name>
- a,b. tlib-version and short-name are required elemets within the taglib element of the the tag library descriptor file.
- a,d. name and tag-class are required elements within the tag element of tag library descriptor file.
- d. tag-class element defines the fully qualified class name of the tag in the TLD file.
- d,f. EVAL_BODY_INCLUDE, and SKIP_BODY are legal return types of doStartTag.
- d,f. EVAL_BODY_AGAIN, and SKIP_BODY are legal return types of doAfterBody.
- a,e. EVAL_PAGE and SKIP_PAGE are legal return types of doEndTag
Post Your Thoughts