Java JSTL / EL: nesting

Posted by NoozNooz42 on Stack Overflow See other posts from Stack Overflow or by NoozNooz42
Published on 2010-05-31T18:01:06Z Indexed on 2010/05/31 18:03 UTC
Read the original article Hit count: 373

Filed under:
|
|

I really don't know how to name this question, it's great if anyone with 2K+ rep can edit this title to better reflect my question (the fact that I can't name this easily is probably why I can't Google the solution).

I've got this, which is working:

<c:choose>
    <c:when test="${sometest}">
        Hello, world!
    </c:when>
    <c:otherwise>
        <fmt:message key="${page.title}" />
    </c:otherwise>
</c:choose>

And I want to change it to this:

<c:choose>
    <c:when test="${sometest}">
        <c:set var="somevar" scope="page" value="Hello, world!"/>
    </c:when>
    <c:otherwise>
        <c:set var="somevar" scope="page" value="<fmt:message key="${page.title}">"
    </c:otherwise>
</c:choose

But of course the following line ain't correct:

<c:set var="somevar" scope="page" value="<fmt:message key="${page.title}">"

How can I assign to the somevar variable the string resulting from a call?

© Stack Overflow or respective owner

Related posts about java

Related posts about jstl