Ch. 9 jsp standard tag library

Preview:

Citation preview

Chapter 9JSP Standard Tag Library (JSTL)

Templates (EL)

EL and standard actions not enough

• Looping

• Flow control

• …

• Install (see page 440 in the book)

• http://cs.roosevelt.edu/eric/books/JSP/jstl-quick-reference.pdf

• JSTL 2.1

the <c:out> tag

• May have attributes too <b>Hello <c:out value=’${user}’ default=’guest’ />.</b>

• May save you from cross-site hacking

Looping without scripting

Servlet code

JSP with scripting

<c:forEach> anatomy

Optional variables

Nesting the loops

<c:if>

<c:choose>, <c:when> & <c:otherwise>

<c:set>

attribute value

target property

<jsp:setProperty>

<c:remove> & <c:import>

include directive or <jsp:include> SA can not do this and many more others

<c:url>

<c:catch>

(in DD also)

Not all errors are catchable

Custom Libraries

• tag name and syntax

• library URI

• TLD (Tag Library Descriptor)

DD  helps

Catch  them  all?

Using  custom  tags:

 the  Tag  Library  Descriptor  (TLD)

Using  custom  tags

Handling  a  custom  tag

<rtexprvalue>  

How  do  they  

match?

Where  are  the  tld’s?

Recommended