jsp tag library

5
JSP Tag Library JSP Tag Library CSCI 4300 CSCI 4300 Notes from Steve Small, Notes from Steve Small, http://www.javaworld.com/ http://www.javaworld.com/ javaworld/jw-02-2003/jw-0228- javaworld/jw-02-2003/jw-0228- jstl.html jstl.html

Upload: aradia

Post on 05-Jan-2016

30 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: JSP Tag Library

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

Page 2: JSP Tag Library

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

Page 3: JSP Tag Library

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" %>

Page 4: JSP Tag Library

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

Page 5: JSP Tag Library

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]}