tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <>
Subject Re: how to use methods with parameters
Date Thu, 05 Feb 2004 18:25:43 GMT
Depends. If you're using a JSP 2.0 container, you can create EL functions that
map to public static Java methods. See section 2.6 of the JSP 2.0 Spec. JSTL 1.1
provides a basic set of EL functions, see section 15 of the JSTL 1.1 Spec.

However, if you're using JSTL 1.0 (JSP 1.2), then you're kind of stuck. The
Unstandard taglib:

provides some support for this through its <invoke> tag, but I'm not sure if the
passing of arguments has been implemented yet.

A somewhat tedious alternative is to create a JavaBean to proxy the method call.
You'd have setter methods for each of the args and then a getter method that
would delegate to the real method you want invoked:

<c:set var="startDate" value="..."/>
<c:set var="endDate" value="..."/>
<jsp:useBean id="daysCalc" class="com.dotech.DaysCalculator"/>
<c:set target="${daysCalc}" property="startDate" value="${startDate}"/>
<c:set target="${daysCalc}" property="endDate" value="${endDate}"/>
<c:out value="${daysCalc.days}"/>

where DaysCalculator.getDays would do something like:

return this.delegate.calculateDays(this.startDate, this.endDate);

Hm, or there might be something fun you could do with a BeanInfo class...

Quoting Just Fun 4 You <>:

> Hi,
> 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?
> thanks.
> Dirk

Kris Schneider <>
D.O.Tech       <>

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

View raw message