x

Java Taglibrary Questions

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.

  1. IterationTag
  2. TagClass
  3. BodyTag
  4. 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.

  1. The prefix defines the name of the tag that may be used for a tag library.
  2. The prefix attribute defines the location of the tag library descriptor file.
  3. 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.
  4. 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.


  1. class-name
  2. tag
  3. class
  4. tag-class
  5. 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

  1. false. Such a class should extend the TagSupport class.
  2. D. BodyTagSupport extends TagSupport and implements interfaces Tag and IterationTag.
  3. false. The tag library descriptor file can have any name. It need not have the name taglib.xml .
  4. 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>.
  5. 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>
  6. a,b. tlib-version and short-name are required elemets within the taglib element of the the tag library descriptor file.
  7. a,d. name and tag-class are required elements within the tag element of tag library descriptor file.
  8. d. tag-class element defines the fully qualified class name of the tag in the TLD file.
  9. d,f. EVAL_BODY_INCLUDE, and SKIP_BODY are legal return types of doStartTag.
  10. d,f. EVAL_BODY_AGAIN, and SKIP_BODY are legal return types of doAfterBody.
  11. a,e. EVAL_PAGE and SKIP_PAGE are legal return types of doEndTag

PREV     NEXT



Like it? Please Spread the word!

Post Your Thoughts