jsp tag library
DESCRIPTION
JSP Tag Library. CSCI 4300 Notes from Steve Small, http://www.javaworld.com/javaworld/jw-02-2003/jw-0228-jstl.html. What is the Tag library?. Creates additional XML-style tags Provide programming functionality with (somewhat) less mess Standard tag library: - PowerPoint PPT PresentationTRANSCRIPT
JSP Tag LibraryJSP Tag Library
CSCI 4300CSCI 4300Notes from Steve Small,Notes from Steve Small,
http://www.javaworld.com/javaworld/jw-http://www.javaworld.com/javaworld/jw-02-2003/jw-0228-jstl.html02-2003/jw-0228-jstl.html
What is the Tag library?What is the Tag library?
• Creates additional XML-style tags
• Provide programming functionality with (somewhat) less mess
• Standard tag library: – Core functions (output, control statements)– Formatting– Internationalization– SQL
Installing the standard libraryInstalling the standard library
• Download and install JSTL support in Tomcat
• Declare in web.xml:• <taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri> <taglib-location>/WEB-INF/c.tld</taglib-location> </taglib>
• Include taglib descriptor file c.tld in WEB-INF• <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
Core STL ExampleCore STL Example
• <b>Parameter values passed to this page for each parameter: </b>•
<table border="2"><c:forEach var="current" items="${param}"> <tr> <td> <b><c:out value="${current.key}" /></b> </td> <c:forEach var="aVal" items="${paramValues[current.key]}"> <td> <c:out value="${aVal}" /> </td> </c:forEach> </tr></c:forEach></table>
• Param and paramValues are global Map vars from Web container
JSP Expression LanguageJSP Expression Language
• Similar to PHP or Perl string interpolation
• ${variable-name} = value of that variable• <c:out value="${anExpression}"/>
<c:out value="literalText${anExpression}${anotherExpression}"/><c:out value="literalText"/>
• ${anObject.aProperty}${anObject["aPropertyName"]}${anObject[aVariableContainingPropertyName]}