I am using weblogic 6.0. i want to use taglib with my
jsp ... so i created a simple tag & am trying to use it ... but it dosnt work. Plz let me know where am i doing anything wrong......
am CONFUSED..
Here is my web.xml
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 1.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<taglib>
<taglib-uri>hello</taglib-uri>
<taglib-location>>/WEB-INF/tlds/hello.tld</taglib-location>
</taglib>
</web-app>
here is my hello.tld
<!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>
<tag>
<name>hello</name>
<tagclass>com.hello.Hello</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>name</name>
<required>false</required>
<rtexpvalue>false</rtexpvalue>
</attribute>
</tag>
</taglib>
I created following folder under WEB-INF
/WEB-INF/tlds/
in this folder i have hello.tld
/WEB-INF/com/hello/
i have my Hello.class under this dir.
Hello.java is as under
package com.hello;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
/**
* This is a simple tag example to show how content is added to the
* output stream when a tag is encountered in a JSP page.
*/
public class Hello extends TagSupport {
private
String name=null;
/**
* Getter/Setter for the attribute name as defined in the tld file
* for this tag
*/
public void setName(String value){
name = value;
}
public String getName(){
return(name);
}
/**
* doStartTag is called by the JSP container when the tag is encountered
*/
public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
out.println("<table border='1'>");
if (name != null)
out.println("<tr><td> Hello " + name + " </td></tr>");
else
out.println("<tr><td> Hello World </td></tr>");
} catch (Exception ex) {
throw new Error("All is not well in the world.");
}
// Must return SKIP_BODY because we are not supporting a body for this
// tag.
return SKIP_BODY;
}
}
here is the Hello.jsp which uses hello taglib...
<%@ taglib uri="hello" prefix="sample" %>
<sample:hello name="Sue"/>
but then also i get the error :
weblogic.servlet.jsp.JspException : could not parse deployment descripter: java.io.IOException: cannot resolve 'hello' into a valid tag library...
can u plz help me out....
thnks in advance
This uri="/hello" must be the same as in web.xml
eg:
<taglib>
<taglib-uri>/hello</taglib-uri>
<taglib-location>/WEB-INF/tlds/hello.tld</taglib-location>
</taglib>
Check every file and you can clear your problem.