Q:

Assigning outcome of another JSTL tag as value of one JSTL tag

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 to fmt:message? 

A:

The fmt:message has a var attribute as well which does effectively what you want. 
 <fmt:message key="${page.title}" var="somevar" />

That's all.  Bookmark the JSTL tlddoc, it may come in handy. 

A:

It is also possible to specify the value to set using the contents of the body, rather than through the value attribute: 
<c:set var="somevar" scope="page">
  <fmt:message key="${page.title}"/>
</c:set>

A:

You'll have to do with:
<c:set var="title"><fmt:message key="${page.title}"></c:set>
<c:set var="somevar" scope="page" value="${title}" />

Since you can't use <fmt:message .. /> on that spot is my experience, has to do with nesting like you suggested.  Or go with @balusc suggestion ;-)

