1

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!

You Qi
  • 8,353
  • 8
  • 50
  • 68

1 Answers1

1

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}">
Zann Anderson
  • 4,767
  • 9
  • 35
  • 56
Selvakumar Ponnusamy
  • 5,363
  • 7
  • 40
  • 78
  • Thanks. but what if it's a static final reference from a class instead of session attribute? for example: `<% out.println(Books.AUTHOR); %>` – You Qi Nov 16 '11 at 03:26
  • Its not possible using standard EL. You have to write your own. You may go thru the below URL for more details http://stackoverflow.com/questions/3732608/how-to-reference-constants-in-el – Selvakumar Ponnusamy Nov 16 '11 at 05:25