1

I am new to jsp and jstl technology. I am trying to print out a some text in <c:out value>, please see point 1 in code. I am trying to display a text like this -

Account Manager-5

Here ${aStageRole.displayName} = 'Account Manager' and (pro.stageRoles) is an array which length is 5.

<select id="selectRole<%=i %>" onchange="javascript:selectRole('selectRole<%=i %>')">
    <c:forEach items="${pro.stageRoles}" var="aStageRole" varStatus="status">
        <option value="${aStageRole.role.id}"> <c:out value="${aStageRole.displayName}-{fn:length(pro.stageRoles)}"/></option>  //1
    </c:forEach>                
</select>

But the code outputs the following value in the dropdown -

Account Manager-{fn:length(pro.stageRoles)}

Can anyone help me how can I solve this problem?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
  • 1
    You could try using value="${aStageRole.displayName + "-" + fn:length(pro.stageRoles)}" – rickz Dec 22 '14 at 00:28

1 Answers1

0

Expressions in JSTL are enclosed by ${}. The part of code {fn:length(pro.stageRoles)} is not evaluated as JSP EL without $ sign.

${fn:length(pro.stageRoles)}
Roman C
  • 49,761
  • 33
  • 66
  • 176