tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre Delisle <Pierre.Deli...@Sun.COM>
Subject Re: how to use methods with parameters
Date Thu, 05 Feb 2004 18:22:05 GMT

> is it possible to use JSTL for an expression like
> <%=calculateDays(startDate, endDate) %> ???
> probably not, but I am too new to JSTL to figure it out by myself. Could
> someone advise me?

This could be possible through an EL function (introduced in JSP 2.0).
The syntax would be as follows:

  ${acme:calculateDays(startDate, endDate)}

You'd have to define in one of your classes a static method "calculateDays" with the proper
signature (Date, Date). The name, class, and signature would then have to be defined
within a <function> element in a TLD.

Here is a snapshot of 'fn.tld' for the standardized functions 
in JSTL 1.1:

<?xml version="1.0" encoding="UTF-8" ?>

<taglib xmlns=""
  xsi:schemaLocation=" web-jsptaglibrary_2_0.xsd"
  <description>JSTL 1.1 functions library</description>
  <display-name>JSTL functions</display-name>

      Tests if an input string contains the specified substring.
    <function-signature>boolean contains(java.lang.String, java.lang.String)</function-signature>
      &lt;c:if test="${fn:contains(name, searchString)}">

    -- Pierre

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message