Question

I have crated a custom tld file. And included in my jsp.

myJsp

<%@ taglib uri="/WEB-INF/Tag.tld" prefix="Tag" %>
...
pageContext.setAttribute("pageBean", myPageBean);
pageContext.setAttribute("formBean", myformBean);
...
<Tag:draw pageBean="${pageBean}" Data="${formBean}"/>

my Tag.tld looks like below

<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd">
<tlib-version>1.0</tlib-version>
<short-name>ct</short-name>
<uri>/WEB-INF/customTag</uri>
<tag>
    <name>draw</name>
    <tag-class>com.myPackage.calling.someOther.Class</tag-class>
    <body-content>empty</body-content>
    <info>Creates a graph based on the supplied input bean</info>
    <attribute>
        <name>Data</name>
        <required>true</required>
        <description>Provide a form graph bean</description>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <name>pageBean</name>
        <required>true</required>
        <description>Provide a Page Graph bean</description>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
</tag>

Now I need to put a stack trace here. Need to know if my jsp is properly importing this tld file. Need to have some line which would SOP from tld file ???

Was it helpful?

Solution

The tag is declared and described in the TLD. The TLD doesn't contain any executable code.

The implementation of the tag is in the class specified in the TLD: com.myPackage.calling.someOther.Class. Put all the code you want in this class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top