JSTL: JSP Standard Tag Library Kick Start

JSTL: JSP Standard Tag Library Kick Start

by Jeff Heaton

Paperback

$29.45 $34.99 Save 16% Current price is $29.45, Original price is $34.99. You Save 16%.

Overview

JSTL makes it simple to integrate programming logic with HTML tags, creating code that is easier to read, reuse, and maintain. JSTL can control conditional processing, access SQL and XML data, and allow you to incorporate other Internet resources into your own site. Plus, JSP's new expression language (EL) allows you to further manipulate application data. JSTL Kick Start will get you started with JSTL quickly. It includes dozens of real-world examples demonstrating common JSTL use, including a complete message forum application. See how the forum is built and then extend it for Spanish or Chinese users with JSTL internationalization tags. Finally, build your own custom tag libraries to further enhance your JSP development.

Product Details

ISBN-13: 9780672324505
Publisher: Pearson Education
Publication date: 09/28/2002
Pages: 417
Product dimensions: 7.30(w) x 9.00(h) x 1.00(d)

Table of Contents

Introduction1
The Benefits of JSTL1
JSTL and JSP2
Who This Book Is For2
Structure and Organization of the Book2
The Forum Application3
Source Code and Updates3
1Understanding JSP Custom Tags5
The Role of Tags in JSP6
Using HTML6
Using JSP Scriptlets7
Programming in Tags8
Introducing JSTL11
The Apache Taglibs Project11
The Structure of JSTL11
Installing JSTL13
Adding JSTL to Your Web Server13
Using JSTL in Your JSP Pages14
Testing the Counting Example15
Troubleshooting the Counting Example17
Summary17
2Programming the JSP Standard Tag Library19
Understanding Scoped Variables20
Page Scope21
Request Scope27
Session Scope27
Application Scope28
Accessing Application Data30
Accessing Page Context Data30
The ParamValues Collection35
The Basics of Web Application Programming41
Processing the Query String41
Working with Forms44
Understanding State46
Summary50
3Understanding Basic Tag Logic51
Exception Processing51
Generating Exceptions52
Using the [left angle bracket]c:catch[right angle bracket] Tag54
Using Conditionals57
Using the [left angle bracket]c:if[right angle bracket] Tag58
Using the [left angle bracket]c:choose[right angle bracket] Tag61
Using the [left angle bracket]c:when[right angle bracket] Tag61
Using the [left angle bracket]c:otherwise[right angle bracket] Tag63
Nesting Conditionals65
A Chat Application65
Summary71
4Using the Expression Language73
JSTL Expression Tags73
Using the [left angle bracket]c:out[right angle bracket] Tag74
Using the [left angle bracket]c:set[right angle bracket] Tag78
Using the [left angle bracket]c:remove[right angle bracket] Tag83
Using the EL Expression Language85
Accessing Properties85
Literals87
Property Access Operators: and88
Arithmetic Operators89
Relational Operators91
Logical Operators92
The and and or Operators92
Operator Precedence93
Reserved Words93
Implicit Objects94
Type Conversion95
Using the RT Expression Language96
Determining the Browser97
Case-Insensitive String Comparisons99
Summary100
5Collections, Loops, and Iterators101
Understanding Collections101
The Iteration Tags102
The [left angle bracket]c:forEach[right angle bracket] Tag102
Loop Status103
Using Iterators106
Iterating over Strings106
Fixed-Length Loops108
The [left angle bracket]c:forTokens[right angle bracket] Tag110
Modifying a Collection113
Tag Collaboration with a Fixed Loop117
Tag Collaboration with a Collection120
Summary122
6Formatting Data with Tags123
Formatting123
Using the [left angle bracket]fmt:formatNumber[right angle bracket] Tag124
Formatting Percents130
Using the [left angle bracket]fmt:formatDate[right angle bracket] Tag134
Parsing140
Using the [left angle bracket]fmt:parseNumber[right angle bracket] Tag140
Using the [left angle bracket]fmt:parseDate[right angle bracket] Tag146
Time Zones151
Setting Time Zones151
Using Time Zones153
Applying Date Formatting156
Summary163
7Accessing Data with SQL Tags165
Introducing the Forum Example165
Database Layout166
Screen Layout174
Understanding JDBC Drivers175
Connecting to a JDBC Data Source175
Using the [left angle bracket]sql:setDataSource[right angle bracket] Tag176
Connecting to Other Databases181
Using SQL Tags181
Using the [left angle bracket]sql:query[right angle bracket] Tag181
Using the [left angle bracket]sql:update[right angle bracket] Tag183
Using the [left angle bracket]sql:transaction[right angle bracket] Tag184
Using the [left angle bracket]sql:param[right angle bracket] Tag185
Using the [left angle bracket]sql:dateParam[right angle bracket] Tag186
Implementing the Forum Example186
Using a Query to Log In186
Using an Update to Register193
Welcome to the Forum198
Using Transactions to Administer the Forum203
A General Query Engine207
Summary211
8Accessing Data with XML Tags213
Understanding XML213
Understanding XPath216
Understanding XML Core Tags216
Using the [left angle bracket]x:parse[right angle bracket] Tag217
Using the [left angle bracket]x:out[right angle bracket] Tag222
Using the [left angle bracket]x:set[right angle bracket] Tag225
Using XML Flow-Control Tags227
Using the [left angle bracket]x:forEach[right angle bracket] Tag227
Using the [left angle bracket]x:if[right angle bracket] Tag231
Using the [left angle bracket]x:choose[right angle bracket] Tag231
Using the [left angle bracket]x:when[right angle bracket] Tag235
Using the [left angle bracket]x:otherwise[right angle bracket] Tag235
Transforming XML with XSLT236
Using the [left angle bracket]x:transform[right angle bracket] Tag238
Using the [left angle bracket]x:param[right angle bracket] Tag241
Summary244
9Accessing Internet Resources with JSTL245
The URL-Related Tags245
Using the [left angle bracket]c:import[right angle bracket] Tag246
Using the [left angle bracket]c:url[right angle bracket] Tag251
Using the [left angle bracket]c:param[right angle bracket] Tag252
Using the [left angle bracket]c:redirect[right angle bracket] Tag256
Understanding Internet Resources260
Introducing RSS261
Using the RSS Format264
Summary267
10Understanding JSTL Internationalization269
The 118N-Related Tags269
Using the [left angle bracket]fmt:setLocale[right angle bracket] Tag270
Using the [left angle bracket]fmt:setBundle[right angle bracket] Tag272
Using the [left angle bracket]fmt:bundle[right angle bracket] Tag273
Using the [left angle bracket]fmt:message[right angle bracket] Tag274
Using the [left angle bracket]fmt:param[right angle bracket] Tag276
Using the [left angle bracket]fmt:requestEncoding[right angle bracket] Tag277
Resource Bundles277
What Is a Resource Bundle?278
Creating a Properties File Resource Bundle279
Creating a Resource Bundle for a Romance Language279
Creating a Resource Bundle for a Non-Romance Language285
Compiling the Resource Bundles287
A Multilingual Forum Application288
Summary294
11Creating Your Own Tag Libraries295
Developing Custom Tag Libraries295
Tags Used by the Forum Application296
Data Structures Used by the Forum Application297
The Components of a Tag Library305
The Tag Library Descriptor File (TLD)305
Updating web.xml for Custom Tags308
Creating the Tag Classes311
Constructing the Tags321
Creating the JAR File332
Using the Tags from JSP333
Summary338
12Debugging and Deploying Tag Libraries339
Debugging339
General Exceptions340
A JSTL-Specific Error341
An Error in a Tag Library343
Debugging with an IDE344
Introducing Eclipse345
Using Eclipse with Tomcat346
Creating Your Own Project350
Debugging the Forum Application350
Deploying Web Applications352
Understanding WAR Files352
Distributing a WAR File353
Summary355
Appendixes
AJSTL Reference357
The Core Tags357
The [left angle bracket]c:catch[right angle bracket] Tag358
The [left angle bracket]c:choose[right angle bracket] Tag358
The [left angle bracket]c:forEach[right angle bracket] Tag358
The [left angle bracket]c:forTokens[right angle bracket] Tag359
The [left angle bracket]c:if[right angle bracket] Tag360
The [left angle bracket]c:import[right angle bracket] Tag360
The [left angle bracket]c:otherwise[right angle bracket] Tag361
The [left angle bracket]c:out[right angle bracket] Tag361
The [left angle bracket]c:param[right angle bracket] Tag362
The [left angle bracket]c:redirect[right angle bracket] Tag362
The [left angle bracket]c:remove[right angle bracket] Tag363
The [left angle bracket]c:set[right angle bracket] Tag363
The [left angle bracket]c:url[right angle bracket] Tag364
The [left angle bracket]c:when[right angle bracket] Tag365
The I18N Tags365
The [left angle bracket]fmt:bundle[right angle bracket] Tag365
The [left angle bracket]fmt:formatDate[right angle bracket] Tag366
The [left angle bracket]fmt:formatNumber[right angle bracket] Tag366
The [left angle bracket]fmt:message[right angle bracket] Tag368
The [left angle bracket]fmt:param[right angle bracket] Tag369
The [left angle bracket]fmt:parseDate[right angle bracket] Tag370
The [left angle bracket]fmt:parseNumber[right angle bracket] Tag371
The [left angle bracket]fmt:requestEncoding[right angle bracket] Tag372
The [left angle bracket]fmt:setBundle[right angle bracket] Tag372
The [left angle bracket]fmt:setLocale[right angle bracket] Tag373
The [left angle bracket]fmt:setTimeZone[right angle bracket] Tag373
The [left angle bracket]fmt:timeZone[right angle bracket] Tag374
The Relational Database Tags (SQL)374
The [left angle bracket]sql:dateParam[right angle bracket] Tag374
The [left angle bracket]sql:param[right angle bracket] Tag374
The [left angle bracket]sql:query[right angle bracket] Tag375
The [left angle bracket]sql:setDataSource[right angle bracket] Tag376
The [left angle bracket]sql:transaction[right angle bracket] Tag376
The [left angle bracket]sql:update[right angle bracket] Tag377
The XML Tags378
The [left angle bracket]x:choose[right angle bracket] Tag378
The [left angle bracket]x:forEach[right angle bracket] Tag378
The [left angle bracket]x:if[right angle bracket] select Tag379
The [left angle bracket]x:otherwise[right angle bracket] Tag379
The [left angle bracket]x:out[right angle bracket] Tag379
The [left angle bracket]x:param[right angle bracket] Tag380
The [left angle bracket]x:parse[right angle bracket] Tag380
The [left angle bracket]x:set[right angle bracket] Tag381
The [left angle bracket]x:transform[right angle bracket] Tag381
The [left angle bracket]x:when[right angle bracket] Tag383
BInstalling JSTL and Tomcat385
Installing JDK385
Installing Tomcat386
Installing the Book Examples389
The Classpath and Search Path390
Installing JSTL without the Examples391
CInstalling MySQL395
Obtaining and Installing MySQL395
Setting Up MySQL397
Creating the Forum Example401
Installing a JDBC Driver402
DUnix Installation Notes405
Index407

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews