Programming WebLogic JSP Tag Extensions

Programming WebLogic JSP Tag Extensions

Understanding and Creating Custom JSP Tags

Programming WebLogic JSP Tag Extensions

javax.servlet.jsp.tagextAPI is available at.

interface if you are creating a custom tag that does not need access to its interface. The API also provides a convenience class

interface and provides default empty methods for the methods defined in the interface.

interface if your custom tag needs to use a body. The API also provides a convenience class

interface and provides default empty methods for the methods defined in the interface. Because

it is a super set of the interface methods.

javax.servlet.jsp.tagext.IterationTag

that controls the reevaluation of the body.

javax.servlet.jsp.tagext.SimpleTaginterface if you wish to use a much simpler invocation protocol. TheSimpleTaginterface does not extend thejavax.servlet.jsp.tagext.Taginterface as does theBodyTaginterface. Therefore, instead of supporting the doStartTag() and doEndTag() methods, theSimpleTaginterface provides a simple doTag() method, which is called once and only once for each tag invocation.

SimpleTagSupport,TagSupport, andBodyTagSupportclasses implement theSimpleTag,TagorBodyTaginterfaces and are included in the API.

tag library. You define a tag library by a tag library descriptor (.tld) file. The TLD describes the syntax for each tag and ties it to the Java classes that execute its functionality.

.tld) file. To use a custom tag library from a JSP page, reference its tag library descriptor with a%@ taglib %directive. For example:

%@ taglib uri=myTLD prefix=mytaglib %

that is defined in the Web application deployment descriptor

directive would reference its tag library descriptor

in the Web application deployment descriptor like this:

taglib-urimyTLD/taglib-uri

taglib-locationlibrary.tld/taglib-location/taglibprefixprefixattribute assigns a label to the tag library. You use this label to reference its associated tag library when writing your pages using custom JSP tags. For example, if the library (calledmytaglib) from the example above defines a new tag callednewtag, you would use the tag in your JSP page like this:mytaglib:newtag

empty tag, or can contain a body, called abody tag. Both types of tags can accept a number of attributes that are passed to the Java class that implements the tag. For more details, seeHandling Exceptions within a Tag Body.

h2This is the body of tagA/h2

You have seen this text mytaglib:counter / times!

only sees the HTML output from its evaluated body. That is, the nested JSP tags

are first evaluated and their output becomes part of the evaluated body of the

output is not further interpreted as JSP

tag library. For more information, seeImplementing the Tag Handler.

directive. A tag library is a collection of JSP tags. Include this directive at the top of your JSP source. For more information, seeConfiguring JSP Tag Libraries.