JSTL to Java Scriplet
March 26, 2009
Scope:
When you want to use an EL variable exposed by a JSTL tag in an expression in the page’s scripting language, you use the standard JSP element jsp:useBean to declare a scripting variable.
Solution Example:
<!-- first set the desired jstl variable and then export it to java -->
<c:set var="productGroup" value="${product.productGroup}"/>
<jsp:useBean id="productGroup" type="java.lang.Integer"/>
<!-- then simply access it in java -->
<%= ProductGroup.getDisplayName( productGroup ) %>
… that’s it.
Wa’Allahu A’lam.
References:
Trackback this post | Subscribe to the comments via RSS Feed