10. Learning Java: JSTL – a rant

On 10th hours, it is JSTL (JavaServer Page Standard Tag Library). We can mix JSP scriptlets with HTML but that takes on readability. JSTL help us there. JSTL can do most common things we usually do in web development.
First need to add library from Project Properties -> add library -> JSTL.

Include tag library to use:
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="core" %>

JSTL code:

        <core:out value="<h1>Hello World!</h1>"/>
        <core:set var="testVar" value="testVal"></core:set>
        <core:out value="${testVar}"></core:out>
        <core:remove var="testVar"></core:remove>
        <p>Test again after var removed:</p>
        <core:out value="${testVar}"></core:out> <%-- no error --%>
        <core:if test="${5 < 6}">
            <core:out value="It is true"></core:out>
        <core:forEach step="1" begin="1" end="10" var="i">
            No#:<core:out value="${i}"/>


<h1>Hello World!</h1> testVal

Test again after var removed:

It is true
No#:1 No#:2 No#:3 No#:4 No#:5 No#:6 No#:7 No#:8 No#:9 No#:10

Hmm! How to render H1 and not show here?

Also, learned <core:choose ><core:when /></core:when>,  <core:forTokens />.

Just few links:

Comments are open for an year period. Please, write here on Facebook page.