Question

I'm looking for method to inject value into a <c:if test>. The code below works if I substitute

<% out.print(request.getSession().getAttribute("UserName").toString()); %>

with some constants. But how can I parse a value in <%%> tag into a <c:if test>?

<netui-data:repeater dataSource="pageFlow.availableBooks">
    <tr>
        <td><netui:label value="${container.item.bookName}" /></td>
        <td>
            <c:if test="${container.item.createdBy == '<% out.print(request.getSession().getAttribute("UserName").toString()); %>'}">
            <netui:anchor action="removeBookAction" value="Remove" formSubmit="true">
                <netui:parameter name="bookID" value="${container.item.bookID}" />
            </netui:anchor>
            </c:if>
        </td>
    </tr>
</netui-data:repeater>

Thanks in advance!

Was it helpful?

Solution

You can use sessionScope to read the value from session scope. The following will help you to resolve:

<c:if test="${container.item.createdBy == sessionScope.UserName}">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top