Home | E-mail 

Java SCJP 6 Exam Download              Java SCJP 6 Exam Details

Exam Notes for the Sun Certified Web Component Developer (SCWCD) Exam

Section 12: Designing and Developing A Custom Tag Library

12.1 Identify the tag library descriptor element names that declare the following:

  • The name of the tag <name>

  • The class of the tag handler <tag-class>

  • The type of content that the tag accepts <body-content>

  • Any attributes of the tag

<attribute>

<name>username</name>

<rtexprvalue>true</rtexprvalue>

<required>false</required>

<type>String</type>

</attribute>

<!ELEMENT taglib (tlib-version, jsp-version, short-name,

uri?, display-name?, small-icon?, large-icon?, description?, validator?, listener*,

tag+) >

<!ELEMENT tag (name, tag-class, tei-class?, body-content?, display-name?,

small-icon?, large-icon?, description?, variable*, attribute*, example?) >

<!ELEMENT variable ( (name-given | name-from-attribute), variable-class?, declare?,

scope?, description?) >

 

<!ELEMENT attribute (name, required? , rtexprvalue?, type?, description?) >  

12.2 Identify the tag library descriptor element names that declare the following:

  • The name of a tag attribute - <name>

  • Whether a tag attribute is required - <required>

  • Whether or not the attribute's value can be dynamically specified - <rtexprvalue>

12.3 Given a custom tag, identify the necessary value for the bodycontent TLD element for any of the following tag types:

  • Empty-tag  - empty

  • Custom tag that surrounds other JSP code – JSP (default, even if there’s no body-content element)

  • Custom tag that surrounds content that is used only by the tag handler - tagdependent

12.4 Given a tag event method (doStartTag, doAfterBody, and doEndTag), identify the correct description of the methods trigger.

doStart – Process the start tag for this instance

doAfterBody – Process body (re)evaluation – repeat for iteration tag.

doEndTag – Process the end tag for this instance. Used to clean up resources and add any closing tags to the output as necessary

12.5 Identify valid return values for the following methods:

·         doStartTag - Tag.EVAL_BODY_INCLUDE,

BodyTag.EVAL_BODY_BUFFERED,

Tag.SKIP_BODY

·         doAfterBody – IterationTag.EVAL_BODY_AGAIN, Tag.SKIP_BODY

·         doEndTag – Tag.EVAL_PAGE, Tag.SKIP_PAGE

·         PageContext.getOut - javax.servlet.jsp.JspWriter

12.6 Given a "BODY" or "PAGE" constant, identify a correct description of the constant's use in the following methods:

  • doStartTag

  • doAfterBody

  • doEndTag

EVAL_BODY_AGAIN

Request the reevaluation of some body. Returned from doAfterBody. For backward compatibility with JSP 1.1, the value is carefully selected to be the same as, now deprecated, BodyTag.EVAL_BODY_TAG. Defined in IterationTag.

EVAL_BODY_TAG

            Deprecated now. Defined in BodyTag

EVAL_BODY_BUFFERED

Request the creation of new buffer, a BodyContent on which to evaluate the body of this tag. Returned from doStartTag when it implements BodyTag. This is an illegal return value for doStartTag when the class does not implement BodyTag. Defined in BodyTag.

EVAL_BODY_INCLUDE

Evaluate body into existing out stream. Valid return value for doStartTag. Defined in Tag.

SKIP_BODY

Skip body evaluation. Valid return value for doStartTag and doAfterBody. Defined in Tag.

EVAL_PAGE

Continue evaluating the page. Valid return value for doEndTag(). Defined in Tag.

SKIP_PAGE

Skip the rest of the page. Valid return value for doEndTag. Defined in Tag.

 

doStart

doAfterBody

doEndTag

EVAL_BODY_INCLUDE

All

 

 

EVAL_BODY_BUFFERED

Body tag only

 

 

EVAL_BODY_AGAIN

 

Iteration

 

SKIP_BODY

All

All

 

EVAL_BODY_TAG

deprecated

EVAL_PAGE

 

 

All

SKIP_PAGE

 

 

All

12.7 Identify the method in the custom tag handler that accesses:

  • A given JSP page's implicit variable

  • The JSP page's attributes

A PageContext instance provides access to all the namespaces associated with a JSP page, provides access to several page attributes, as well as a layer above the implementation details.

The following methods provide convenient access to implicit objects:

getOut(), getException(), getPage() getRequest(), getResponse(), getSession(),

getServletConfig() and getServletContext().

The following methods provide support for forwarding, inclusion and error handling:

forward(), include(), and handlePageException().

The methods related to attributes are:

setAttribute(), getAttribute(), removeAttribute() – deals page scope

findAttribute(), - looks in all scopes

int getAttributesScope() and getAttributeNamesInScope(int scope)

Note:

TagSupport implements IterationTag which extends Tag.  BodyTagSupport implements BodyTag which extends IterationTag.

getPreviousOut(), getBodyContent(), setBodyContent(), doInitBody() methods are defined in BodyTagSupport.

12.8 Identify methods that return an outer tag handler from within an inner tag handler.

Tag Tag.getParent()

Tag TagSupport.getParent()

Tag TagSupport.findAncestorWithClass(Tag from, java.lang.Class class) (A static method)

 

Previous                                                   Contents                                                         Next 

Privacy Policy Legal Contact webmaster Web design by anandsoft