File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Configure EL function in tag library descriptor? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Configure EL function in tag library descriptor?" Watch "Configure EL function in tag library descriptor?" New topic

Configure EL function in tag library descriptor?

vishwa venkat
Ranch Hand

Joined: Nov 22, 2003
Posts: 185
can some one explanisn how to do configuring EL function in tag library descriptor?Please give an example showing how to use thius function also,
Dimple Kaushik
Ranch Hand

Joined: Nov 19, 2003
Posts: 49
From Online resources
Expression Language Functions:
When the EL moved from the JSTL specification to the JSP specification, it picked up a new trick: namely, how to invoke functions. The EL function syntax is simple: the function name, followed by a list of arguments within parenthesis:
<%@ taglib prefix="fn"
uri="" %>

A function belongs to a tag library and the function name includes the prefix assigned to the library with the taglib directive in the page. In this example, I use the prefix fn, which is the default prefix for the JSTL function library.
The Tag Library Descriptor (TLD) maps the function name to a static method in a Java class that implements the functionality:

Returns the number of items in a collection or the number of
characters in a string.
int length(java.lang.Object)

The most interesting element here is the <function-signature> element. It contains a declaration of the type of value the function returns, the name of the static implementation method, and type declarations for all arguments (zero or more, comma-separated) within parenthesis. The return type and the argument types must be either Java primitive types or fully qualified type names.
The static method for the length() function is implemented like this in the Jakarta Taglibs Standard library:

public static int length(Object obj)
throws JspTagException {
if (obj == null)
return 0;
if (obj instanceof String)
return ((String)obj).length();
if (obj instanceof Collection)
return ((Collection)obj).size();
if (obj instanceof Map)
return ((Map)obj).size();
int count = 0;
if (obj instanceof Iterator) {
Iterator iter = (Iterator) obj;
count = 0;
while (iter.hasNext()) {
return count;
if (obj instanceof Enumeration) {
Enumeration enum = (Enumeration) obj;
count = 0;
while (enum.hasMoreElements()) {
return count;
try {
count = Array.getLength(obj);
return count;
} catch (IllegalArgumentException ex) {}
throw new JspTagException("Unsupported type"));

As you see, there's nothing strange going on here. It's a regular static method that finds out the length its argument using an approach suitable to the specific runtime type of the argument.
Hope this helps.
[ February 02, 2004: Message edited by: Dimple Kaushik ]
[ February 02, 2004: Message edited by: Dimple Kaushik ]
Sumit Amar
Ranch Hand

Joined: Jun 08, 2002
Posts: 180
Good example, thanks.

SCJP, SCWCD, OCA, OCP-DBA 9i, <a href="" target="_blank" rel="nofollow">BCIP</a>, MCP, MCAD, MCSD.NET, MCDBA, MCTS (SQL 05), MCITP (DBD, DBA)
Ali Ragi
Ranch Hand

Joined: Dec 10, 2003
Posts: 60
Hi Dimple Kaushik,
Your comments is a great help, thanks!
One more question: As far as I know, EL can only use those static functions, which being developed for the EL used. I am wondering whether EL can use or call other class object's static and instance method on the fly, like the length()in String class? Thanks in advance!
vishwa venkat
Ranch Hand

Joined: Nov 22, 2003
Posts: 185
Thanks a lot..
I agree. Here's the link:
subject: Configure EL function in tag library descriptor?
It's not a secret anymore!