Hi i'm new bie in custom tags. While experimenting with the stuff, i got the folowing error. Can anybody sort it out??
Cheers
Prasad
I'm attaching the codes..\
myTag.java
-------------------------------------------------
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
class myTag implements Tag{
private PageContext pageContext;
private Tag parent;
public myTag(){
super();
}
public int doStartTag() throws JspTagException{
return SKIP_BODY;
}
public int doEndTag() throws JspTagException{
try{
pageContext.getOut().write("Hello world byb prasad");
}catch(java.io.IOException e){
throw new JspTagException("IO exception"+e.getMessage());
}
return EVAL_PAGE;
}
public void release(){}
public void setPageContext(PageContext pContext){
this.pageContext=pContext;
}
public void setParent(Tag parent){
this.parent=parent;
}
public Tag getParent(){
return this.parent;
}
}
mytags.tld
-------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD
JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>my</shortname>
<tag>
<name>hello</name>
<tagclass>myTag</tagclass>
<bodycontent>empty</bodycontent>
<info>My Tag</info>
</tag>
</taglib>
body.jsp
--------------------------------------------------
<%@ taglib uri="/WEB-INF/mytags.tld" prefix="my" %>
<--------------------------
<br><br><br><br><br>====<b>Body 1</b>====<br><br><br><br><br>
<my:hello />
Error i got
--------------------------------------------------
[ServletException in:body.jsp] Unable to compile class for JSP An error occurred at line: 7 in the jsp file: /body.jsp Generated
servlet error: C:\Tomcat4.0\work\Standalone\localhost\Tiles\body$jsp.java:63: Class org.apache.jsp.myTag not found. myTag _jspx_th_my_hello_0 = new myTag(); ^ An error occurred at line: 7 in the jsp file: /body.jsp Generated servlet error: C:\Tomcat4.0\work\Standalone\localhost\Tiles\body$jsp.java:63: Class org.apache.jsp.myTag not found. myTag _jspx_th_my_hello_0 = new myTag(); ^ 2 errors ' org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 7 in the jsp file: /body.jsp Generated servlet error: C:\Tomcat4.0\work\Standalone\localhost\Tiles\body$jsp.java:63: Class org.apache.jsp.myTag not found. myTag _jspx_th_my_hello_0 = new myTag(); ^ An error occurred at line: 7 in the jsp file: /body.jsp Generated servlet error: C:\Tomcat4.0\work\Standalone\localhost\Tiles\body$jsp.java:63: Class org.apache.jsp.myTag not found. myTag _jspx_th_my_hello_0 = new myTag(); ^ 2 errors at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285) at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:497) at org.apache.jasper.runtime.JspRuntimeLibrary