I have three cookies, two of them are used to keep the details of user (name and id) and the other one is to keep the type of user. I need to show a specific message based on type of user which is retrieved from one of the cookies.
I have the following working code but it is a bit complex, I am wondering if there is any efficient way to do it.
<c:forEach items="${cookie}" var="IdCookie">
<c:if test="${IdCookie.key == 'UserID'}"> << if UserID cookie is found
<c:forEach items="${cookie}" var="nameCookie">
<c:if test="${nameCookie.key == 'User'}"> << if User cookie is found
<p>${IdCookie.value.value} ${nameCookie.value.value}</p>
<c:forEach items="${cookie}" var="typeCookie">
<c:if test="${typeCookie.key == 'Type'}"> << if Type cookie is found
<c:if test="${typeCookie.value == 'One'}">
<p>,Your type is one </p>
</c:if>
<c:if test="${typeCookie.value == '0'}">
<p>,Your type is NOT one </p>
</c:if>
</c:if>
</c:forEach>
</c:if>
</c:forEach>
</c:if>
</c:forEach>
Output
Cookies' values >> 1 Alex 0
output >> 1 Alex,Your type is Not one
Cookies' values >> 1 Jack One
output >> 1 Jack,Your type is one