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 --%>
<hr>
<core:if test="${5 < 6}">
<core:out value="It is true"></core:out>
</core:if>
<hr>
<core:forEach step="1" begin="1" end="10" var="i">
No#:<core:out value="${i}"/>
</core:forEach>
Output:
<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:
- An-Introduction-to-JSP-Standard-Template-Library-JSTL.htm
- library/j-jstl0211.html
- JSTL3.html
- tutorial/doc/JSTL4.html#wp67593
- javaee/5/tutorial/doc/bnakd.html
- javaee/5/jstl/1.1/docs/tlddocs/
- http://download-llnw.oracle.com/javaee/5/tutorial/doc/bnakc.html
- JSP: http://download-llnw.oracle.com/javaee/5/tutorial/doc/bnagx.html
- http://www.java-tips.org/java-tutorials/tutorials/introduction-to-jstl-using-netbeans-4.html
Comments (1)