Java Reference
In-Depth Information
After filling out the fields in the Insert JSTL If window as shown in the screenshot
and clicking OK , the following markup is generated in our page.
<c:if test="${param.displayConditionalText == 'true'}"
var="textDisplayed" scope="session">
Additionally, NetBeans adds a taglib directive at the top of the JSP markup. The
taglib directive tells our JSP that we will be using custom tags in the page. For core
JSTL tags, the taglib directive looks like this:
<%@ taglib prefix="c" uri="" %>
We, of course need to add some markup between the <c:if> and </c:if> tags,
whatever we add between these two tags will only be rendered if the condition
inside the test attribute is true.
After adding some markup both before, inside and after the <c:if> tag, the body of
our page now looks like this:
<h2>Hello World!</h2>
This paragraph will always be displayed.
<c:if test="${param.displayConditionalText == 'true'}"
var="textDisplayed" scope="session">
This paragraph will only be displayed if the request parameter named
"displayConditionalText" has a value of "true".
This paragraph will also always be displayed.
</p> </body>
We can see how the page is displayed in the browser by right-clicking on it and
selecting Run File from the resulting pop up menu.
Please note that if we haven't deployed our project, NetBeans
may complain about the JSTL libraries not being present. To
solve this issue, we simply need to right-click on our project
and click Deploy .
Search WWH ::

Custom Search