Reputation: 4557
Is it possible that some content of the .jsp page(say form) is displayed only if a bool variable's value of this jsp page is true?
Thanks for considering my question.
Upvotes: 1
Views: 1230
Reputation: 2138
Use scriptlets for example
<%
if (condition)
{
%>
your code
<%
}
else
{
%>
your code
<%
}
%>
Scriptlets are used for writing java codes.. If you want to get the the value of a variable use
<%=var %>
for example
<% if(id==1)
{
%>
<tr>
<td class="BodyStyle"><h5 align="left"><%=TokenNo%></h5></td>
<td class="BodyStyle"><h5 align="left"><%=Time%></h5></td>
<td class="BodyStyle"><h5 align="left">Booked</h5></td>
</td>
</tr>
<%
}
else
{
%>
<tr>
<td class="BodyStyle"><h5 align="left"><%=TokenNo%></h5></td>
<td class="BodyStyle"><h5 align="left"><%=Time%></h5></td>
<td class="BodyStyle"><h5 align="left">Available</h5></td>
</tr>
<%
}
%>
Upvotes: 0
Reputation: 10239
Use <c:if>
from JSTL tag library.
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
...
<c:if test="${myBooleanVariable}">
<form>
...
</form>
</c:if>
Upvotes: 2