0

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 ???

Some Java Guy
  • 4,992
  • 19
  • 71
  • 108
  • 1
    I don't understand your question. You need to include a stack trace where? What does SOP mean? What does the tag do or should do? – JB Nizet Jan 13 '12 at 07:50
  • SOP: System.out.println("The JSP just called this tld") It has to be in the tld file. So I could look in the tomcat console. – Some Java Guy Jan 13 '12 at 09:17

1 Answers1

1

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.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255