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:

Using JSTL

Entry Filed under: Java, jstl. .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Recent Posts

Recent Comments

Categories

Top Posts

Links

Blog Stats

Meta