Sometimes you run into a scenario where you have an evaluated EL expression property, that is used widely through your JSF page. Evaluating the value each time is a waste of performance.
JSTL core <c:set> helps you caching the value into a scoped variable, that can be accessed later on through the scope it’s defined on.

First add the JSTL core library to your project. If you’re on Maven you can add the next <dependency>


Or get the jstl-1.2.jar

The xlmns namespace to use it in your page:


Now here’s how it works:

<c:set var="myCachedValue" value="#{myBean.someProperty}" />

When #{myBean.someProperty} is evaluated, it will be stored into the scoped var="myCachedValue" and it’s available to be accessed after:

<h:outputText value="#{myCachedValue}" />

Also note the scope property of set tag, which defines the scope of the created var.
Check the <c:set> Documentation for further info.