Hi,
I was trying the sample program of SCWCD Exam Study Kit 2nd Edition shown chapter 13. Below are the details:
1) StrMethods.java
package myFunc;
public class StrMethods{
public static
String upper(String x){
return x.toUpperCase();
}
public static int length(String x){
return x.length();
}
}
2) Functions.tld
<taglib 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"
version="2.0">
<tlib-version>1.0</tlib-version>
<function>
<name>upper</name>
<function-class>myFunc.StrMethods</function-class>
<function-signature>
java.lang.String upper(java.lang.String)
</function-signature>
</function>
<function>
<name>length</name>
<function-class>myFunc.StrMethods</function-class>
<function-signature>
java.lang.int length(java.lang.String)
</function-signature>
</function>
</taglib>
3) deployment descriptor
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<taglib>
<taglib-uri>
http://myFunc/Functions </taglib-uri>
<taglib-location>
/WEB-INF/myFunc/Functions.tld
</taglib-location>
</taglib>
</web-app>
4) Stringfun.jsp
<%@ taglib prefix="myString" uri="http://myFunc/Functions" %>
<html>
<body>
<b>Enter Text : </b>
<form action="Stringfun.jsp" method="GET">
<input type="text" name="str">
<p><input type="submit">
</form>
<% String x = request.getParameter("str"); %>
<table border="1">
<tr>
<td>Uppercase:</td>
<td>${myString:upper('str')}</td>
</tr>
<tr>
<td>Length:</td>
<td>${myString:length("str")}</td>
</tr>
</table>
</body>
</html>
Location of the files: (I'm using
Tomcat 5)
1. StrMethods.class --> inside webapps/chapter13/WEB-INF/classes/myFunc
2. Functions.tld --> inside webapps/chapter13/WEB-INF/myFunc
3. web.xml --> inside webapps/chapter13/WEB-INF
4. Stringfun.jsp --> inside webapps/chapter13
The output should display to uppercase the string that the user entered in the text field and also display the length of the string.
However when I run this:
http://localhost/chapter13/Stringfun.jsp. I'm not getting what I expected.
