TagLib application in JSP (4-2)

Source: Internet
Author: User

When processing custom tags, We need to overload the doStartTag () and doEndTag () of the parent class. If the tag attribute is defined in the tld file, you need to define the corresponding setxxx/getxxx method for each attribute in tag handler.

In doStartTag (), the TemplateParameter object is obtained from the Hashtable defined by the Template class.

In doEndTag (),

PageContext. getRequest (). getRequestDispatcher (templateParam. getValue (). include (pageContext. getRequest (), pageContext. getResponse ());

This is the content generated by returning the resource object (RequestDispatcher) specified by the tag attribute value through the context of the jsp page ..

DoStartTag () and doEndTag () return values are static int defined in Tag Interface

SKIP_BODY implicit 0

Skip body evaluation. Valid return value for doStartTag and doAfterBody. Skip the processing of the body.

The code between the start and end labels is skipped.

EVAL_BODY_INCLUDE implicit 1

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

This is an illegal return value for doStartTag when the class implements BodyTag,

Since BodyTag implies the creation of a new BodyContent.

Output the body content to an existing output stream. Including jsp code or output

SKIP_PAGE implicit 5

Skip the rest of the page. Valid return value for doEndTag.

Ignore the remaining pages.

EVAL_PAGE implicit 6

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

Continue to execute the following page

There are references to other classes in this class, so I will not list them. You can study them by yourself.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.