I'm using JSTL in jsp and want to output value in textarea
<tr>
<th scope="row">SMS Before Inst</th>
<td colspan="7"><textarea cols="20" rows="5" placeholder="SMS Content" id=smsMessage name="smsMessage">
Time setting is
<c:choose>
<c:when test="${CTSSessionCode=='M'}">
Morning
</c:when>
<c:when test="${CTSSessionCode=='E'}">
Everning
</c:when>
<c:otherwise>
OTHER
</c:otherwise>
</c:choose>
Date
<c:out value="${requestDate}" ></c:out>
,We will contact later
</textarea></td>
</tr>
within, CTSSessionCode = M is Morning, CTSSessionCode = E is Everning, and requestDate is date, but when i run it it output is blank and space character.
How to fix the problem ?
CodePudding user response:
Instead of this structure the <textarea>
:
<textarea>
value
</textarea>
You can try with this:
<textarea>value</textarea>
And move <c:choose>
condition outside the <textarea>
:
<c:set var="myVar" value="OTHER"></c:set>
<c:choose>
<c:when test="${CTSSessionCode=='M'}">
<c:set var="myVar" value="Morning"></c:set>
</c:when>
<c:when test="${CTSSessionCode=='E'}">
<c:set var="myVar" value="Everning"></c:set>
</c:when>
</c:choose>
<tr>
<th scope="row">SMS Before Inst</th>
<td colspan="7">
<textarea cols="20" rows="5" placeholder="SMS Content" id=smsMessage name="smsMessage">Time setting is ${myVar} Date ${requestDate}, We will contact later</textarea>
</td>
</tr>