tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karr, David" <David.K...@wamu.net>
Subject RE: accessing static fields/methods from a static class using jstl el
Date Wed, 05 Feb 2003 19:58:20 GMT
> -----Original Message-----
> From: Donald Ball [mailto:dball@rhoworld.com]
> 
> hi, i'm trying to figure out how to access static fields or methods
from a
> static class using the jstl el. say i've got a class, call it
> com.example.Foo, which has a method getBar(). how would i access that
> property using jstl el? this doesn't work:
> 
> ${com.example.Foo.bar}
> 
> for, i guess, relatively obvious reasons. any suggestions? this seems
like
> a really stupid question, but i've been poking around for a while and
> can't
> figure out a solution without reverting to scriptlets. thanks.

The JSTL EL can reference javabean properties, maps, and collections.
That's it.  The JSTL specification describes this, although I wish it
had a concise statement to this effect.  You sort of have to figure this
out by deduction.

One curious strategy for accessing static variables would be to create
an object that gets associated with another class, which uses reflection
to load all the "static final" members into a map.  You could then
reference the map entries in the JSTL EL.  Obviously, you would have to
put that created object into one of the available scopes.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message