SCWCD : Custom Tag Library Mock Exam Practice Questions
Questions no -1
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.
options
A)The prefix defines the name of the tag that may be used for a tag library.
B)The prefix attribute defines the location of the tag library descriptor file.
C)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
D)The prefix attribute is used in front of a tagname of a tag defined within the tag library.
Correct answer is : D
Explanations : If the taglib directive directive defines a prefix of "test", and a tag is called "mtag",
then the tag is used as "test:mtag".
Questions no -2
Given a tag handler defined with JSP which implements TagSupport and ONLY overrides doAfterBody with the following lines:
public int doAfterBody() throws JspException {
try { pageContext.getOut().print("Hi");}catch(IOException e) {}
return SKIP_BODY;
}
What will be the result of a jsp with the following part?
<prefix:sufix>
<i>Hello</i>
</prefix:sufix>
options
A)The jsp page will print: Hello
B)The jsp page will print: Hello Hi
C)The jsp page will print: Hi Hello
D)The jsp won't print anything
Correct answer is : D
Explanations : TagSupport.doStartTag by default returns SKIP_BODY and as it is not overridden the body is ignored.
|