Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Taglib  RSS feed

 
priya shankar
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I am using tomcat3.2..i tried to reun a taglib...but probs...
TagHandler Class
public class sect extends TagSupport
{
publlic String name;
public void setName(String name)
{
this.name=name;
}
public int doStartTag()
{
try
{
JspWriter out=JspWriter.getOut();
out.println("name"+name);
}
catch(Exception e)
{
s.o.p(e);
}
retrun EVAL_BODY_INCLUDE;
}
}
public int doEndTag()
{
try
{
JspWriter out=JspWriter.getOut();
out.println("name"+name);
}
catch(Exception e)
{
s.o.p(e);
}
retrun EVAL_PAGE;
}
}
}
my TLD
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>name</shortname>
<info>fsd</info>
<tag>
<name>first</name>
<taglibclass>sect</taglibclass>
<bodycontent>JSP</bodycontent>
<attribute>
<name>name</name>
<required>true</required>
</attribute>
</tag>
</taglib>
MY JSP
<%@ taglib uri="sec.tld" prefix="one"%>
<one:first name="ammu">Hi every Body</one:first>
I copied
1)sec.class to tomcat(root)/webapps/examples/WEB-INF/classes
2)sec.tld to tomcat/webapps/examples/META-INF
3)sec.jsp to tomcat/webapps/examples
i run the prog as http:\\localhost:8080\examples\sec.jsp
I got the page that shows namenull ..nothing more than this...
i didn,t give the attribute ,bodycontent...
what is the problem....
help pls
thankx
priya
 
Debashish Chakrabarty
Ranch Hand
Posts: 231
Firefox Browser Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you tried this code? As far as I can comprehend the class would not compile owing to usage of "return", "public", code for getting the JspWriter object etc etc. I hope these are only typos. Also in your tld file element <taglibclass> should perhaps be <tagclass>. Lastly keeping your tld file in "META-INF" would serve no purpose perhaps.
Try putting the "sec" class in a package and specifying the proper path for tld in the JSP (say "/WEB-INF/sec.tld" if you put the tld there).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!