Prefer JSTL tags

JSTL is a standard set of tags used for implementing common tasks in Java Server Pages. It's probably best to prefer the JSTL over other tag libraries, if possible, since the average web programmer can be expected to be familiar with it.

To give an example of typical JSTL syntax, here are some JSP snippets which use the core, format, and function parts of JSTL:

<%@ taglib uri="" prefix="c" %>  
<%@ taglib uri="" prefix="fmt" %>
<%@ taglib prefix="fn" uri="" %> 

<c:forEach var="restaurant" items="${itemsForListing}" varStatus="index">
 <tr class="row_highlight">
  <td title="Line Number">${index.count}</td>
  <td align="center">${restaurant.location}</td>
  <td align="center">${restaurant.comment}</td>

System Properties (${fn:length(systemProperties)})
<c:forEach var="entry" items="${systemProperties}">
 <b>${entry.key}</b> = ${entry.value}

<jsp:useBean id="now" class="java.util.Date" />
Copyright <fmt:formatDate value="${now}" pattern="yyyy" /> 

See Also :
Emit flexible URLs
Always maintain HttpSessions
Would you use this technique?
Yes   No   Undecided   
© 2018 Hirondelle Systems | Source Code | Contact | License | RSS
Individual code snippets can be used under this BSD license - Last updated on September 21, 2013.
Over 2,000,000 unique IPs last year - Built with WEB4J.
- In Memoriam : Bill Dirani -