• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simple tag handler

 
sai kunala
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I wrote a simple tag handler

When i try to compile the jsp it saying unable to load the taghandlerclass

Im using NetBeans IDE 6.0

Please help me solve the issue.

My tagHandlerclass is as follows it is located in the src pacakge


import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.JspException;


public class NewTagHandler1 extends SimpleTagSupport {


public void doTag() throws JspException {

JspWriter out=getJspContext().getOut();

try {

out.print("Thisis the simple tag handler");
JspFragment f=getJspBody();
if (f != null) f.invoke(out);



} catch (java.io.IOException ex) {
throw new JspException(ex.getMessage());
}

}
}
............................................................................

My tld is as follows


<?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>tld2</short-name>
<uri>WEB-INF/tlds/tld2</uri>


<tag>
<name>NewTagHandler1</name>
<tag-class>NewTagHandler1</tag-class>
<body-content>scriptless</body-content>
</tag>
</taglib>

..........................................................................

My Jsp is as follows located in WEB-INF

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="hi" uri="WEB-INF/tlds/tld2.tld" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>

<hi:NewTagHandler1>
Hi thisis a sample jsp
</hi:NewTagHandler1>

</body>
</html>


Thanks and Regards

Aparna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic