Apache Jakarta and Beyond: A Java Programmeramp;#039;s Introduction [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Apache Jakarta and Beyond: A Java Programmeramp;#039;s Introduction [Electronic resources] - نسخه متنی

Larne Pekowsky

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







18.1. Tag Libraries


Before jumping into the full standard tag library, it helps to consider how pages load and use simpler tags. Listing 18.1 uses a simple tag that displays the date and time in a configurable format,


Listing 18.1. A JSP that uses a custom tag


<%@ taglib prefix="awl"
uri="http://toolbook.awl.com/samples"%>
The time, in two different formats:<p>
<awl:date format="EEEE, MMMM dd yyyy 'at' hh:mm"/><br>
<awl:date format="hh:mm:ss MM/dd/yy"/><br>

The tag library is loaded with the first line. The URI specifies the location of the tag library definition, and the prefix specifies the name that will be used to access the tags. Here the prefix is awl, but it could be anything as long as it is used consistently. One of the tags from this library, date, isused twice in the last two lines. The name of the tag is prepended by the prefix specified at the top.[1]

[1] Formally, the tag lives in an XML namespace specified by the prefix. Custom tags can be loaded with any namespace, so formally the portion before the colon is not part of the name. However, in the text this prefix will always be included to avoid possible confusion between tags such as c:param and sql:param.


The awl:time tag itself simply sends the current time to the page in a format specified by the format property. In one sense this is not a particularly good example. Tags are intrinsically part of the view portion of an application, and so dealing with issues such as formatting a time for presentation is perfectly valid. However, the tag in

/ 207