Java Reference
In-Depth Information
After dropping the
JSTL Choose
item into the appropriate location in our page, we
are prompted for additional information.
The JSTL
<c:when>
tag needs to have one or more nested
<c:when>
tags, and
optionally, a
<c:otherwise>
tag. In the
Insert JSTL Choose
window we indicate
how many
<c:when>
tags we need, and if we need a
<c:otherwise>
statement.
After filling out the fields in the
Insert JSTL Choose
window, as shown in the
screenshot, the following markup is generated in our page.
<c:choose>
<c:when test="">
</c:when>
<c:when test="">
</c:when>
<c:otherwise>
</c:otherwise>
</c:choose>
We of course need to fill the body and the value of the test attribute for each
<c:
when>
tag, and the body of the
<c:otherwise>
tag. After doing just that and adding
some additional markup both before and after the
<c:choose>
tag, the body of our
page now looks like this:
<body>
<h2>Hello World!</h2>
<p>
This paragraph will always be displayed.
</p>
<p>
<c:choose>
<c:when
test="${param.displayConditionalText == '1'}">
This paragraph will only be displayed if the request
parameter named "displayConditionalText" has a value