Home > Guides > Tag Developers Guide > JSP > Access to ValueStack from JSPs |
To access the ValueStack from third-party JSP taglibs, expose property values to JSP using the <s:set
tag.
After setting parameters, third-party JSP taglibs can access variables or use JSP 2.0 EL (Expression Language). This is convenient as short hand EL expression syntax
${expression
}
can be used in a text or inside of tag attributes:
In practice, several variables must be exposed to make effective use of third party taglibs like DisplayTag. Unfortunately, this approach leads to a lot of <ww:set/>
tags.
There is a simple, if not elegant, solution available in JSP 2.0 EL, for exposing ValueStack to OGNL. It is possible to create custom functions that can be called from EL expressions. Functions have to be 'public static' and specified in a TLD file.
To use a function, import the TLD in a JSP file where you've want to use a function. For example, you could access Action properties by evaluating OGNL expression by a function 'vs' (for valuestack) in EL.
To use this code you've got to add wwel.tld
and Functions.java
to your webapp project.