March 2, 2011

JSTL 1.1 - <c:if> example


<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<% request.setAttribute("userType","premium"); %>
<c:if test="${requestScope.userType == 'premium'}" var="isPremiumMember" scope="session" >
   Welcome! You are a privileged customer.
</c:if>
<br/>
<c:out value="${sessionScope.isPremiumMember}" />

prints,

Welcome! You are a privileged customer.
true

No comments:

Post a Comment