Mr. Desai:
I am happy to see someone has used Custom Tags on the WebLogic server. I have been stuck with this problem for a long time. Both Mr. Phil Hanna (the author of several books) and Ms. Maha Anna helped in looking at my source code. My code works on their
Tomcat. I think that I put all the files under the right directories, I cannot stop wondering if I made mistakes in compiling the tag handler class, ExampleTag.java. I keep getting this error message using the WebLogic 5.1 and WebLogic 6.0:
Parsing of JSP File '/SimpleExample.jsp' failed:
---------------------------------------------------------------
/SimpleExample.jsp(6): Could not parse deployment descriptor: java.io.IOException: cannot resolve 'csajsp-taglib.tld' into a valid tag library
probably occurred due to an error in /SimpleExample.jsp line 6:
<%@ taglib uri="csajsp-taglib.tld" prefix="csajsp" %>
---------------------------------------------------------------
There are five, but very small files involved. Please allow me to load my source code:
1. The Web application deployment descriptor, web.xml, under
c:\bea\wlserver6.0sp1
\config\mydomain\applications\DefaultWebApp_myserver
\WEB-INF
<?xml version="1.0" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<taglib>
<taglib-uri>csajsp-taglib.tld</taglib-uri>
<taglib-location>csajsp-taglib.tld</taglib-location>
</taglib>
</web-app>
Note: I also tried to change <taglib-location> element to
<taglib-location>/WEB-INFO/csajsp-taglib.tle</taglib-location>
2. The tag library descriptor file, csajsp-taglib.tld, which is a .xml file, is under the same directory as where web.xml is
c:\bea\wlserver6.0sp1
\config\mydomain\applications\DefaultWebApp_myserver
\WEB-INF
<?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">
<!-- a tag library descriptor -->
<taglib>
<!-- after this the default space is
"http://java.sun.com/j2ee/dtds/jsptaglibrary_1_2.dtd"
-->
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>csajsp</shortname>
<uri></uri>
<info>
A tag library from Core Servlets and JavaServer Pages,
http://www.coreservlets.com/. </info>
<tag>
<name>example</name>
<tagclass>coreservlets.tags.ExampleTag</tagclass>
<info>Simplest example: inserts one line of output</info>
<!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
<bodycontent>empty</bodycontent> -->
</tag>
</taglib>
3. The JSP page, SimpleExample.jsp is under
c:\bea\wlserver6.0sp1
\config\mydomain\applications\DefaultWebApp_myserver
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<%@ taglib uri="csajsp-taglib.tld" prefix="csajsp" %>
<TITLE><csajsp:example /></TITLE>
<LINK REL=STYLESHEET
HREF="JSP-Styles.css"
TYPE="text/css">
</HEAD>
<BODY>
<H1><csajsp:example /></H1>
<csajsp:example />
</BODY>
</HTML>
4. The style sheet that is used in the JSP page, JSP-Styles.css, is in the same directory as where the JSP page is
<STYLE TYPE="text/css">
<!--
BODY { background-color: #FDF5E6 }
A:hover { color: red }
H1 { color: #440000;
text-align: center;
font-family: Arial Black, Arial, Helvetica, sans-serif
}
H2 { color: #440000;
text-align: left;
font-family: Arial, Helvetica, sans-serif
}
H3 { color: #440000;
text-align: left;
font-family: Arial, Helvetica, sans-serif
}
UL { margin-top: 0;
border-top-width: 0;
padding-top: 0
}
DT { font-weight: bold;
}
PRE { font-size: 105%;
}
CODE { font-size: 105%;
}
.TOC { font-size: 90%;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif
}
TH.COLORED { background-color: #FFAD00
}
TR.COLORED { background-color: #FFAD00
}
TH.TITLE { background-color: #EF8429;
font-size: 28px;
font-family: Arial, Helvetica, sans-serif;
}
-->
</STYLE>
5. The tag handler
Java class file, ExampleTag.class, is under
c:\bea\wlserver6.0sp1
\config\mydomain\applications\DefaultWebApp_myserver
\WEB-INF\classes\coreservlets\tags
and the below is the source code for the tag handler Java file, Example.java
package coreservlets.tags;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class ExampleTag extends TagSupport {
public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
out.print("Custom tag example " +
"(coreservlets.tags.ExampleTag)");
} catch(IOException ioe) {
System.out.println("Error in ExampleTag: " + ioe);
}
return(SKIP_BODY);
}
}
Could you detect what went wrong? Many, many thanks