- JSP without JSTL
<% for(int i=0; i<messages.length; i++) {
String message = messages[i];
%>
<LI><%= message %>
<% } %>
</UL>
- JSP with JSTL
<c:forEach var="message" items="${messages}">
<LI>${message}
</c:forEach>
</UL>
<c:out value="${foo}" default="${calculatedValue}"/>
<c:if test="${someTest}">
Content
</c:if>
<c:choose>
<c:when test="test1">Content1</c:when>
<c:when test="test2">Content2</c:when>
...
<c:when test="testN">ContentN</c:when>
<c:otherwise>Default Content</c:otherwise>
</c:choose>
<c:import>
- Read content from arbitrary URLs
- Insert into page
- Store in variable
- Or make accessible via a reader
- Unlike <jsp:include>, not restricted to own system
<c:param>
– Encodes a request parameter and adds it to a URL
– May be used within body of <c:import> or <c:redirect>
<fmt:formatNumber> Formats a numeric value as a number, currency value, or
percent, in a locale-specific manner
<fmt:parseNumber> Reads string representations of number, currency value, or percent
<fmt:formatDate>
<fmt:parseDate>
<fmt:timeZone>
<fmt:setTimeZone>
Can build your own custom tags based on JSTL tags.
No comments:
Post a Comment