tags:

views:

170

answers:

0

Hi, I've made an application to understand the EL expression. In the TLD file firstly I used just the function name and its return type like- "int length( String x )", then it gives and error but when I replace it with "java.lang.int length(java.lang.String)" the code runs fine. Moreover there is another function where there is no parameter, and its just declared as "int upar()" and it don't give an error. Please explain why this happens, I am really in confusion. Here are the codes for this.

package myFunc;
public class StrMethods 
{
public static int upar()
{
return 11;
}
public static String upper(String x)
{
String y=x.toUpperCase();
return y;
}
public static int length( String x )
{
return x.length();
}

}

the tld file

<?xml version="1.0" encoding="ISO-8859-1"?>
<taglib version="2.0">
    <tlib-version>1.2</tlib-version>
    <uri>hello</uri>
<function>
    <name>upar</name>
    <function-class>myFunc.StrMethods</function-class>
    <function-signature>int upar()</function-signature>
</function>
<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>

and the index.html file

<%@ taglib prefix="myString" uri="hello"%>
<html><body>
<b>Enter text:</b>
<form action="newindex.jsp" method="get">
<input type="text" name="x">
<input type="submit">
</form>
<table border="1">
<tr>
<td>Upar:</td>
<td>${myString:upar()}</td>
</tr>
<tr>
<tr>
<td>upper case:</td>
<td>${myString:upper(param.x)}</td>
</tr>
<tr>
<tr>
<td>length</td>
<td>${myString:length(param.x)}</td>
</tr>


</table>
</body></html>