10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CustomTag Examples<br />

This section introduces examples that demonstrate using custom tags.<br />

Simple Attribute Example<br />

<strong>The</strong> Duke’s Bookstore shipDate tag, defined in<br />

tut-install/javaeetutorial5/examples/web/bookstore3/web/WEB-INF/tags/shipDate.tag,<br />

is a custom tag that has a simple attribute. <strong>The</strong> tag generates the date of a book order according<br />

to the type of shipping requested.<br />

<br />

${param.cardname}.<br />

<br />

,<br />

<br />

<br />

<strong>The</strong> tag determines the number of days until shipment from the shipping attribute passed to it<br />

by the page tut-install/javaeetutorial5/examples/web/bookstore3/web/bookreceipt.jsp.<br />

From the number of days, the tag computes the ship date. It then formats the ship date.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

.<br />

Simple and Fragment Attribute andVariable Example<br />

Encapsulating Reusable Content UsingTag Files<br />

<strong>The</strong> Duke’s Bookstore catalog tag, defined in<br />

tut-install/javaeetutorial5/examples/web/bookstore3/web/WEB-INF/tags/catalog.tag,<br />

Chapter 8 • CustomTags in JSP Pages 241

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!