How can I replace true and false with yes or no using JSP and JSTL? i hava values TRUE and FALSE in my table. i want when i retive these values using jstl on my jsp pages the true false will replace with YES AND NO
+2
A:
I would suggest using a tagfile.
Create the tagfile, (say, /WEB-INF/tags/yesno.tag
) with something like this:
<%@ attribute name="value" type="lava.lang.Boolean" required="true" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:choose><c:when test="${value}">yes</c:when><c:otherwise>no</c:otherwise></c:choose>
Then in your JSP:
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<tags:yesno value=${MyBoolean}"/>
The tagfile is a bit cumbersome, but it's well encapsulated and reusable.
skaffman
2010-06-07 15:26:35
thanks alot.its work.Again thanks Mr skaffman..........
ali
2010-06-07 17:01:20
You should then vote and accept this answer (and review [your previous questions](http://stackoverflow.com/users/346077/mansoor) as well). Also see http://stackoverflow.com/faq to learn how to use stackoverflow properly :)
BalusC
2010-06-07 21:21:54