Table of Contents

bemutefrogtownSecurity

Nov 18, 2013 (3 years and 9 months ago)

84 views


Table of Contents
Introduction .................................................................................................................................................... xv
PART 1: WEB PROGRAMMING CONCEPTS
Chapter 1: Introduction to Web Technologies .............................................................................. 1
History of the Web ................................................................................................................................................................................. 2
 
OSI Reference Model ............................................................................................................................................................................. 2
 
Understanding Web System Architecture ......................................................................................................................................... 4
 
Understanding 3-Tier Web Architecture ........................................................................................................................................... 5
 
TCP/IP ..................................................................................................................................................................................................... 5
 
Layers in the TCP/IP model ................................................................................................................................................................ 6
 
Physical .................................................................................................................................................................................................6
 
Link Layer .............................................................................................................................................................................................7
 
Internet Layer .......................................................................................................................................................................................7
 
Transport Layer ...................................................................................................................................................................................7
 
Application Layer ................................................................................................................................................................................8
 
Web Browsers ......................................................................................................................................................................................... 9
 
Retrieving Documents on the Web: The URL and Domain Name System ...............................................................................9
 
Overview of HTTP ............................................................................................................................................................................... 10
 
Sending the Request ..........................................................................................................................................................................11
 
The Server Response .........................................................................................................................................................................11
 
Using Cookies to Remember User Information .............................................................................................................................. 12
 
Exploring Web Technologies ............................................................................................................................................................. 12
 
HTML ..................................................................................................................................................................................................12
 
Introduction to XML .........................................................................................................................................................................13
 
ASP.NET .............................................................................................................................................................................................14
 
Java ......................................................................................................................................................................................................15
 
AJAX ....................................................................................................................................................................................................15
 
PHP ......................................................................................................................................................................................................16
 
Introduction to Web Services ..........................................................................................................................................................16
 
About IIS ................................................................................................................................................................................................ 16
 
Services Supported by IIS 7 ................................................................................................................................................................ 17
 
The ASP.NET Service........................................................................................................................................................................17
 
The File Transfer Protocol (FTP) Publishing Service ...................................................................................................................17
 
World Wide Web (WWW) Services ...............................................................................................................................................17
 
Simple Mail Transfer Protocol (SMTP) Service ............................................................................................................................17
 
Network News Transfer Protocol (NNTP) Service ......................................................................................................................17
 
Installation of IIS 7 ............................................................................................................................................................................... 18
 
Administer Web Server Remotely ..................................................................................................................................................... 25
 
Installation of Web Server (IIS 7) Management Services ............................................................................................................25
 
Configuration of the Web Server (IIS 7) Management Services ................................................................................................28
 
Creating Web Sites ............................................................................................................................................................................... 32
Apache Tomcat ..................................................................................................................................................................................... 35

Summary ............................................................................................................................................................................................... 38
 
Table of Contents
viii
Quick Revise ......................................................................................................................................................................................... 38
Chapter 2: HTML and JavaScript Programming .......................................................................... 41
HTML ..................................................................................................................................................................................................... 42
 
Introducing HTML Document Structure ......................................................................................................................................... 42
 
The <!DOCTYPE> Element .............................................................................................................................................................43
 
The <html> Element .........................................................................................................................................................................43
 
The <head> Element .........................................................................................................................................................................44
 
The <title> Element ...........................................................................................................................................................................44
 
The <body> Element .........................................................................................................................................................................45
 
Creating Headings on a Web Page .................................................................................................................................................... 48
 
Aligning the Headings .....................................................................................................................................................................49
 
Working with Links ............................................................................................................................................................................. 50
 
Creating a Hyperlink ........................................................................................................................................................................50
 
Setting the Hyperlink Colors ...........................................................................................................................................................51
 
Linking Different Sections of a Web Page .....................................................................................................................................52
 
Creating a Paragraph........................................................................................................................................................................... 54
 
Working with Images .......................................................................................................................................................................... 54
 
Inserting an Image on a Web Page .................................................................................................................................................55
 
Displaying Alternate Text for an Image ........................................................................................................................................56
 
Adding a Border to an Image ..........................................................................................................................................................57
 
Aligning an Image .............................................................................................................................................................................58
 
Using Images as Links ......................................................................................................................................................................59
 
Creating Image Maps........................................................................................................................................................................60
 
Working with Tables ........................................................................................................................................................................... 61
 
Creating a Table .................................................................................................................................................................................62
 
Specifying a Caption to a Table.......................................................................................................................................................63
 
Adding a Table Heading ..................................................................................................................................................................64
 
Setting the Table Border ...................................................................................................................................................................65
 
Aligning a Table and Cell Content .................................................................................................................................................66
 
Setting the Width of a Table and Table Columns ........................................................................................................................69
 
Changing the Background Color of a Table ..................................................................................................................................71
 
Setting Cell Padding and Cell Spacing ..........................................................................................................................................72
 
Spanning Rows and Columns .........................................................................................................................................................75
 
Nesting Tables ...................................................................................................................................................................................77
 
Working with Frames .......................................................................................................................................................................... 79
 
Creating a Frame ...............................................................................................................................................................................79
 
Creating Vertical and Horizontal Frames .....................................................................................................................................80
 
Setting the Frame Border Thickness ...............................................................................................................................................83
 
Applying Hyperlink Targets to a Frame .......................................................................................................................................84
 
Introduction to Forms and HTML Controls .................................................................................................................................... 86
 
Creating an HTML Form..................................................................................................................................................................87
 
Specifying the Action URL and Method to Send the Form ........................................................................................................88
 
Using the HTML Controls ...............................................................................................................................................................89
 
Introducing Cascading Style Sheets .................................................................................................................................................. 98
 
Inline Styles ........................................................................................................................................................................................99
 
External Style Sheets ...................................................................................................................................................................... 100
 
Internal Style Sheets ....................................................................................................................................................................... 102
 
Style Classes .................................................................................................................................................................................... 104
 
Multiple Styles ................................................................................................................................................................................ 105
 
Introducing DHTML ......................................................................................................................................................................... 106
 
Introducing JavaScript ...................................................................................................................................................................... 106
 
Client-Side Benefits of using JavaScript over VB Script ........................................................................................................... 107
 
Embedding JavaScript in an HTML Page .................................................................................................................................. 107
 
Handling Events ............................................................................................................................................................................. 109
 
Using Variables in JavaScript ....................................................................................................................................................... 117
 
Table of Contents
ix
Using Array in JavaScript ............................................................................................................................................................. 121
 
Creating Objects in JavaScript ...................................................................................................................................................... 124
 
Using Operators.............................................................................................................................................................................. 129
 
Working with Control Flow Statements ..................................................................................................................................... 132
 
Summary ............................................................................................................................................................................................. 155
 
Quick Revise ....................................................................................................................................................................................... 155
PART 2: CREATING PHP APPLICATIONS
Chapter 3: Introducing PHP ......................................................................................................... 157
Versions of PHP ................................................................................................................................................................................. 158
 
Features of PHP .................................................................................................................................................................................. 158
 
Introduction to HTML, XHTML, and JavaScript .......................................................................................................................... 159
 
HTML ............................................................................................................................................................................................... 159
 
XHTML ............................................................................................................................................................................................ 160
 
JavaScript ......................................................................................................................................................................................... 161
 
Advantages of PHP over Other Scripting languages ................................................................................................................... 162
 
Active Server Pages ........................................................................................................................................................................ 162
 
Cold Fusion ..................................................................................................................................................................................... 162
 
Practical Extraction and Report Language (Perl) ...................................................................................................................... 162
 
Java Server Pages (JSP) .................................................................................................................................................................. 162
 
Creating a PHP Script ........................................................................................................................................................................ 162
 
Running a PHP Script ....................................................................................................................................................................... 163
 
Handling Errors in a PHP Script ..................................................................................................................................................... 163
 
Escape Characters .............................................................................................................................................................................. 164
 
Summary ............................................................................................................................................................................................. 165
 
Quick Revise ....................................................................................................................................................................................... 165
Chapter 4: Working with Variables and Constants ................................................................... 169
Using Variables .................................................................................................................................................................................. 170
 
Naming Rules and Conventions .................................................................................................................................................. 170
 
Assigning Values to Variables...................................................................................................................................................... 170
 
Destroying Variables ..................................................................................................................................................................... 172
 
Using Constants ................................................................................................................................................................................. 172
 
Exploring Data Types in PHP .......................................................................................................................................................... 173
 
Determining Variable Data Type ................................................................................................................................................. 174
 
Using Type Casting ........................................................................................................................................................................ 175
 
Exploring Operators in PHP ............................................................................................................................................................ 176
 
Assignment Operators ................................................................................................................................................................... 176
 
Arithmetic Operators ..................................................................................................................................................................... 176
 
String Operators ............................................................................................................................................................................. 177
 
Comparison Operators .................................................................................................................................................................. 177
 
Logical Operators ........................................................................................................................................................................... 178
 
Increment/Decrement Operators ................................................................................................................................................ 178
 
Arithmetic Assignment Operators .............................................................................................................................................. 179
 
Operator Precedence ...................................................................................................................................................................... 179
 
Summary ............................................................................................................................................................................................. 180
 
Quick Revise ....................................................................................................................................................................................... 180
Chapter 5: Controlling Program Flow ........................................................................................ 185
Conditional Statements ..................................................................................................................................................................... 186
 
Exploring Different Types of Conditional Statements ............................................................................................................. 186
 
The if Statements ............................................................................................................................................................................ 186
 
Defining the Nested if-else Statements ....................................................................................................................................... 190
 
Combining Conditional Statements ............................................................................................................................................ 191
 
Looping Statements ........................................................................................................................................................................... 191
 
Table of Contents
x
Exploring Different Types of Looping Statements ................................................................................................................... 192
 
Defining the Nested Looping Statement .................................................................................................................................... 195
 
Break, Continue, and Exit Statements ............................................................................................................................................ 195
 
Break statement .............................................................................................................................................................................. 195
 
Continue Statements ...................................................................................................................................................................... 196
 
Exit statement .................................................................................................................................................................................. 197
 
Summary ............................................................................................................................................................................................. 197
 
Quick Revise ....................................................................................................................................................................................... 198
 
Chapter 6: Working with Functions, Arrays, Files, and Directories ........................................ 203
Introduction ........................................................................................................................................................................................ 204
 
User-Defined Functions in PHP ...................................................................................................................................................... 204
 
Naming Conventions ..................................................................................................................................................................... 204
 
Creating and invoking a Function ............................................................................................................................................... 204
 
Returning Value from a Function ................................................................................................................................................ 205
 
Understanding the Variable Scope .............................................................................................................................................. 205
 
Passing Arguments by Reference ................................................................................................................................................ 206
 
Built-in Functions in PHP ................................................................................................................................................................. 207
 
String Manipulation Functions .................................................................................................................................................... 207
 
Date and Time Functions in PHP ................................................................................................................................................ 210
 
Mathematical Functions ................................................................................................................................................................ 213
 
Recursive, Variable, and Callback Functions ................................................................................................................................ 216
 
Introducing Arrays ............................................................................................................................................................................ 217
 
Creating an Array ........................................................................................................................................................................... 217
 
Accessing Array Elements ............................................................................................................................................................ 218
 
Types of Arrays .................................................................................................................................................................................. 219
 
Numeric Arrays .............................................................................................................................................................................. 219
 
Associative Arrays ......................................................................................................................................................................... 219
 
Multidimensional Arrays .............................................................................................................................................................. 219
 
Traversing Arrays using Loops and ArrayIterators ..................................................................................................................... 220
 
The foreach Construct.................................................................................................................................................................... 220
 
The ArrayIterator ........................................................................................................................................................................... 221
 
Built-in Array Functions ................................................................................................................................................................... 222
 
Getting the Size of an Array ......................................................................................................................................................... 222
 
Searching For the Occurrence of a Given Value ........................................................................................................................ 222
 
Sorting an Array ............................................................................................................................................................................. 223
 
Working with Files and Directories ................................................................................................................................................ 224
 
Working with Files ............................................................................................................................................................................ 224
 
Opening a File ................................................................................................................................................................................. 224
 
Closing a File ................................................................................................................................................................................... 225
 
Reading a File .................................................................................................................................................................................. 226
 
Writing a File ................................................................................................................................................................................... 228
 
Retrieving File Status ..................................................................................................................................................................... 229
 
Locking File Using the flock() Function ...................................................................................................................................... 231
 
Working with Directories ................................................................................................................................................................. 232
 
Creating a Directory ....................................................................................................................................................................... 232
 
Deleting a Directory ....................................................................................................................................................................... 233
 
Locating the Current Working Directory ................................................................................................................................... 233
 
Changing a Directory..................................................................................................................................................................... 233
 
Listing Files in a Directory ............................................................................................................................................................ 234
 
Summary ............................................................................................................................................................................................. 235
 
Quick Revise ....................................................................................................................................................................................... 235

Chapter 7: Working with Forms and Database .......................................................................... 241
Table of Contents
xi
Introduction to Web Forms .............................................................................................................................................................. 242
 
Working with the <form> Tag and Form Elements ..................................................................................................................... 242
 
Creating a Text Box ........................................................................................................................................................................ 242
 
Creating a Radio Button ................................................................................................................................................................ 243
 
Creating a Check Box ..................................................................................................................................................................... 244
 
Creating a Drop-Down Box .......................................................................................................................................................... 244
 
Processing a Web Form ..................................................................................................................................................................... 245
 
Submitting the Form Data ............................................................................................................................................................ 245
 
Retrieving the Form Data .............................................................................................................................................................. 247
 
Validating a Form .............................................................................................................................................................................. 250
 
Displaying an Error Message when a Field is Empty .............................................................................................................. 251
 
Enforcing Data Rules ..................................................................................................................................................................... 252
 
Introducing Databases ...................................................................................................................................................................... 254
 
Exploring Relational Database Model, Records, and Primary Keys ...................................................................................... 254
 
Understanding Relationships and Foreign Keys ...................................................................................................................... 255
 
Working with SQL Statements ..................................................................................................................................................... 256
 
Using PHP and MySql ...................................................................................................................................................................... 257
 
Checking Configuration ................................................................................................................................................................ 257
 
Connecting to Database ................................................................................................................................................................. 258
 
Selecting a Database ....................................................................................................................................................................... 259
 
Adding Table in a Database ......................................................................................................................................................... 260
 
Altering a Table in a Database ..................................................................................................................................................... 261
 
Inserting Data in a Table ............................................................................................................................................................... 262
 
Modifying Data in a Table ............................................................................................................................................................ 263
 
Retrieving Data ............................................................................................................................................................................... 264
 
Summary ............................................................................................................................................................................................. 265
 
Quick Revise ....................................................................................................................................................................................... 265
Chapter 8: Exploring Cookies, Sessions, and PHP Security ................................................... 269
Working with Cookies ...................................................................................................................................................................... 270
 
Exploring Cookie Attributes ......................................................................................................................................................... 270
 
Using Cookie Header ..................................................................................................................................................................... 270
 
Creating Cookies ............................................................................................................................................................................ 271
 
Reading Cookies ............................................................................................................................................................................. 271
 
Removing Cookies ......................................................................................................................................................................... 271
 
Storing Arrays in Cookies ............................................................................................................................................................. 272
 
Working with Sessions ...................................................................................................................................................................... 272
 
Starting a Session ............................................................................................................................................................................ 273
 
Adding Session Data ...................................................................................................................................................................... 273
 
Reading Session Data ..................................................................................................................................................................... 274
 
Removing Session Data ................................................................................................................................................................. 274
 
Ending a Session ............................................................................................................................................................................. 274
 
Preventing Session Hijacking ....................................................................................................................................................... 275
 
Do not Trust Unknown or Unauthorized Users ....................................................................................................................... 277
 
Shared Hosting by Using session_save_path() .......................................................................................................................... 277
 
Do not Pass Session Identifier in URLs ....................................................................................................................................... 278
 
Differentiating Cookies and Sessions ............................................................................................................................................. 278
 
Protecting Data ................................................................................................................................................................................... 278
 
Data Encryption .............................................................................................................................................................................. 278
 
Types of Encryption ....................................................................................................................................................................... 278
 
Symmetric Encryption ................................................................................................................................................................... 279
 
Advanced Symmetric Encryption ............................................................................................................................................... 279
 
Symmetric Decryption ................................................................................................................................................................... 280
 
Types of Encryption Algorithm ................................................................................................................................................... 280
 
Types of Block Cipher Mode ........................................................................................................................................................ 281
 
Configuring PHP Security ................................................................................................................................................................ 282
 
Table of Contents
xii
The disable_functions Directive ................................................................................................................................................... 283
 
The disable_classes Directive ....................................................................................................................................................... 283
 
The allow_url_fopen Directive ..................................................................................................................................................... 283
 
The open_basedir Directive .......................................................................................................................................................... 283
 
The error_reporting Directive ...................................................................................................................................................... 283
 
The display_errors Directive ........................................................................................................................................................ 283
 
The log_errors Directive ................................................................................................................................................................ 283
 
The expose_php Directive............................................................................................................................................................. 283
 
The max_input_time Directive ..................................................................................................................................................... 283
 
The session.name Directive .......................................................................................................................................................... 284
 
Summary ............................................................................................................................................................................................. 284
 
Quick Revise ....................................................................................................................................................................................... 284

PART 3: CREATING JAVA WEB APPLICATIONS
Chapter 9: Getting Started with Web Applications in Java ...................................................... 289
Introduction to Web Applications................................................................................................................................................... 290
 
Exploring Java Based Web Technologies ....................................................................................................................................... 290
 
Describing JDBC ............................................................................................................................................................................. 291
 
Describing Servlets ......................................................................................................................................................................... 292
 
Describing JavaServer Pages (JSP) ............................................................................................................................................... 294
 
Introducing Web Architecture Models ........................................................................................................................................... 295
 
Describing the Model-1 Architecture .......................................................................................................................................... 295
 
Describing the Model-2 Architecture .......................................................................................................................................... 296
 
Introducing the MVC Architecture ................................................................................................................................................. 297
 
Describing the Model Component .............................................................................................................................................. 298
 
Describing the View Component ................................................................................................................................................. 298
 
Describing the Controller Component ....................................................................................................................................... 298
 
Summary ............................................................................................................................................................................................. 299
 
Quick Revise ....................................................................................................................................................................................... 299
Chapter 10: Working with JavaBeans ........................................................................................ 301
Introducing JavaBeans ...................................................................................................................................................................... 302
 
Advantages of JavaBeans .............................................................................................................................................................. 303
 
Introspection ................................................................................................................................................................................... 303
 
Customizers ..................................................................................................................................................................................... 303
 
The JavaBeans API ............................................................................................................................................................................. 304
 
Designing Programs Using JavaBeans ........................................................................................................................................... 306
 
Creating a Java Bean .......................................................................................................................................................................... 307
 
Creating a Bean Manifest File ....................................................................................................................................................... 308
 
Creating a Bean JAR File ............................................................................................................................................................... 308
 
Using the New Bean ...................................................................................................................................................................... 309
 
Adding Controls to Beans ................................................................................................................................................................ 309
 
Giving a Bean Properties .................................................................................................................................................................. 310
 
Design Patterns for Properties ......................................................................................................................................................... 315
 
Simple Properties ........................................................................................................................................................................... 315
 
Indexed Properties ......................................................................................................................................................................... 316
 
Using the BeanInfo Interface ............................................................................................................................................................ 316
 
Creating Bound Properties ............................................................................................................................................................... 317
 
Giving a Bean an Icon ........................................................................................................................................................................ 319
 
Creating a BeanInfo Class ................................................................................................................................................................. 319
 
Bound and Constrained Properties ................................................................................................................................................. 320
 
Persistence ........................................................................................................................................................................................... 322
 
Using Beans with JSP pages ............................................................................................................................................................. 323
 

Summary ............................................................................................................................................................................................. 323
 
Table of Contents
xiii
Quick Revise ....................................................................................................................................................................................... 323
Chapter 11: Working with Servlet Programming ....................................................................... 325
What’s New in Servlet 2.5? ............................................................................................................................................................... 326
 
Features of Java Servlets ................................................................................................................................................................... 327
 
Servlet – A Request and Response Model .................................................................................................................................. 328
 
Servlet and Environment State ..................................................................................................................................................... 328
 
Security Features ............................................................................................................................................................................ 329
 
HTML-Aware Servlets................................................................................................................................................................... 330
 
HTTP-Specific Servlets .................................................................................................................................................................. 331
 
Performance Features .................................................................................................................................................................... 331
 
3-Tier Applications ......................................................................................................................................................................... 332
 
Web Publishing System ................................................................................................................................................................. 333
 
Exploring the Servlet API ................................................................................................................................................................. 334
 
The javax.servlet Package ............................................................................................................................................................. 334
 
The javax.servlet.http Package ..................................................................................................................................................... 336
 
Introducing the Servlet Life-Cycle .................................................................................................................................................. 338
 
The init() Method ............................................................................................................................................................................ 339
 
The service() Method ..................................................................................................................................................................... 339
 
The destroy() Method .................................................................................................................................................................... 340
 
Servlet Configuration ........................................................................................................................................................................ 340
 
Servlet Configuration in web.xml ................................................................................................................................................ 341
 
Working with ServletConfig and ServletContext ......................................................................................................................... 342
 
Creating a Sample Servlet ................................................................................................................................................................. 343
 
Directory Structure ......................................................................................................................................................................... 343
 
Configuring the Servlet ................................................................................................................................................................. 344
 
Packaging, Deploying and Running the Web Application ..................................................................................................... 345
 
Working with HttpServletRequest and HttpServletResponse ................................................................................................... 345
 
HttpServletRequest ........................................................................................................................................................................ 345
 
HttpServletResponse ..................................................................................................................................................................... 354
 
Request Delegation and Request Scope ......................................................................................................................................... 359
 
Servlet Collaboration ......................................................................................................................................................................... 363
 
Collaboration through the System Properties List.................................................................................................................... 363
 
Collaboration through a Shared Object ...................................................................................................................................... 364
 
Collaboration through Inheritance .............................................................................................................................................. 371
 
Introducing Session Tracking .......................................................................................................................................................... 373
 
Session Tracking Mechanisms ......................................................................................................................................................... 373
 
Cookies ............................................................................................................................................................................................. 373
 
Hidden Form Fields ....................................................................................................................................................................... 378
 
URL Rewriting ................................................................................................................................................................................ 378
 
Session using Secure Socket Layer (SSL) .................................................................................................................................... 381
 
Session Tracking and Java Servlet API ........................................................................................................................................... 381
 
History of Session Tracking .......................................................................................................................................................... 381
 
Session Creation and Tracking ..................................................................................................................................................... 382
 
Login Application using Session Tracking .................................................................................................................................... 390
 
Directory Structure of Login Application .................................................................................................................................. 390
 
Building the Front-End .................................................................................................................................................................. 391
 
Creating and Managing Session .................................................................................................................................................. 391
 
Configuring the Login Application ............................................................................................................................................. 394
 
Running the Login Application ................................................................................................................................................... 394
 
Summary ............................................................................................................................................................................................. 396
 
Quick Revise ....................................................................................................................................................................................... 396
 

Chapter 12: Working with JSP .................................................................................................... 399
Table of Contents
xiv
Understanding JSP ............................................................................................................................................................................. 400
 
Advantages of JSP over Servlets .................................................................................................................................................. 401
 
Introducing the Tag-Based Approach ......................................................................................................................................... 402
 
Describing the JSP Architecture ................................................................................................................................................... 402
 
Describing the JSP Life Cycle ........................................................................................................................................................... 403
 
The Page Translation Stage ........................................................................................................................................................... 403
 
The Compilation Stage .................................................................................................................................................................. 406
 
The Loading & Initialization Stage .............................................................................................................................................. 406
 
The Request Handling Stage ........................................................................................................................................................ 406
 
The Destroying Stage ..................................................................................................................................................................... 406
 
Creating Simple JSP Pages ................................................................................................................................................................ 407
 
Working with JSP Basic Tags and Implicit Objects ...................................................................................................................... 409
 
Exploring Scripting Tags ............................................................................................................................................................... 410
 
Exploring Implicit Objects ............................................................................................................................................................ 413
 
H2 Exploring Directive Tags ........................................................................................................................................................ 419
 
Using JavaBeans and Action Tags in JSP ....................................................................................................................................... 424
 
What is JavaBean? .......................................................................................................................................................................... 424
 
Action Tags ...................................................................................................................................................................................... 425
 
Using a Bean in a JSP ..................................................................................................................................................................... 437
 
Using the JSP Standard Tag Library (JSTL) ................................................................................................................................... 442
 
Describing JSTL Core Tags ............................................................................................................................................................... 443
 
General-Purpose Tags ................................................................................................................................................................... 443
 
Conditional and Looping Tags .................................................................................................................................................... 446
 
Networking Tags ............................................................................................................................................................................ 453
 
Describing the JSTL SQL Tags ......................................................................................................................................................... 454
 
Types of JSTL SQL Tags ................................................................................................................................................................ 454
 
Using JSTL SQL Tags ..................................................................................................................................................................... 456
 
JSTL Formatting Tags ........................................................................................................................................................................ 458
 
Basic Formatting Tags ................................................................................................................................................................... 458
 
Number Formatting Tags.............................................................................................................................................................. 462
 
Date Formatting Tags .................................................................................................................................................................... 465
 
Time Zone Formatting Tags ......................................................................................................................................................... 468
 
JSTL XML Tags ................................................................................................................................................................................... 470
 
XML Core Tags ............................................................................................................................................................................... 471
 
XML Flow Control Tags ................................................................................................................................................................ 471
 
XML Transformation Tags ............................................................................................................................................................ 473
 
Implementing JSTL Tags .................................................................................................................................................................. 473
 
Summary ............................................................................................................................................................................................. 477
 
Quick Revise ....................................................................................................................................................................................... 477
 
Chapter 13: Java Database Programming ................................................................................. 479
Introduction to JDBC ......................................................................................................................................................................... 481
 
Components of JDBC ..................................................................................................................................................................... 481
 
JDBC Specification.......................................................................................................................................................................... 482
 
JDBC Architecture .......................................................................................................................................................................... 482
 
JDBC Drivers ....................................................................................................................................................................................... 483
 
Describing the Type-1 Driver ....................................................................................................................................................... 483
 
Describing the Type-2 Driver(Java to native API) .................................................................................................................... 484
 
Describing the Type-3 Driver (Java to Network Protocol/All Java Driver) ......................................................................... 486
 
Describing the Type-4 Driver (Java to Database protocol) ...................................................................................................... 487
 
Features of JDBC ................................................................................................................................................................................ 488
 
New Features in JDBC 4.0 ............................................................................................................................................................. 489
 
Describing the JDBC API’s ............................................................................................................................................................... 491
 
The java.sql Package ...................................................................................................................................................................... 491
 
The javax.sql Package .................................................................................................................................................................... 494
 
Describing the Major Classes and Interfaces ................................................................................................................................. 495
 
Table of Contents
xv
Understanding the DriverManager Class .................................................................................................................................. 495
 
Understanding the Driver Interface ............................................................................................................................................ 496
 
Understanding the Connection Interface ................................................................................................................................... 497
 
Understanding the Statement Interface ...................................................................................................................................... 499
 
Implementing JDBC Processes with java.sql Package ................................................................................................................. 502
 
Basic JDBC Steps ............................................................................................................................................................................. 503
 
Creating a Simple JDBC Application .......................................................................................................................................... 505
 
Working with the PreparedStatement Interface ....................................................................................................................... 509
 
Working with the CallableStatement Interface ......................................................................................................................... 514
 
Working with ResultSets ............................................................................................................................................................... 522
 
Working with Batch Updates ....................................................................................................................................................... 532
 
Describing SQL 99 Data Types ..................................................................................................................................................... 536
 
Implementing JDBC Processes with the javax.sql Package ........................................................................................................ 553
 
Using DataSource to Make a Connection ................................................................................................................................... 553
 
Describing Connection Pooling ................................................................................................................................................... 554
 
Using RowSet Objects .................................................................................................................................................................... 558
 
Working with Transactions .............................................................................................................................................................. 571
 
Describing ACID Properties ......................................................................................................................................................... 572
 
Types of Transactions .................................................................................................................................................................... 572
 
Performing Transaction Management ........................................................................................................................................ 573
 
Summary ............................................................................................................................................................................................. 576
 
Quick Revise ....................................................................................................................................................................................... 576
PART 4: CREATING ASP.NET APPLICATIONS
Chapter 14: ASP.NET 3.5 Essentials .......................................................................................... 577
New Features in ASP.NET 3.5 ......................................................................................................................................................... 578
 
ASP.NET AJAX Support ............................................................................................................................................................... 578
 
The ListView Control ..................................................................................................................................................................... 578
 
The DataPager Control .................................................................................................................................................................. 578
 
Support for WCF Services ............................................................................................................................................................. 579
 
WCF Support for RSS, JSON, and Partial Trust ........................................................................................................................ 579
 
Support for Nested Master Pages at Design Time .................................................................................................................... 579
 
Merge Tool in ASP.NET 3.5 .......................................................................................................................................................... 579
 
Improved Support for JavaScript Debugging ........................................................................................................................... 579
 
Support for Microsoft Office 2007 Applications ....................................................................................................................... 580
 
The ASP.NET Life Cycle ................................................................................................................................................................... 580
 
ASP.NET Application Life Cycle on IIS 7.0 ............................................................................................................................... 580
 
ASP.NET Page Life Cycle.............................................................................................................................................................. 583
 
Overview of Visual Studio 2008 ...................................................................................................................................................... 585
 
New Features in Visual Studio 2008 ............................................................................................................................................... 585
 
Support for Multi-Targeting ......................................................................................................................................................... 585
 
Support for ASP.NET AJAX and JavaScript Intellisense ......................................................................................................... 586
 
Support for Language Integrated Query .................................................................................................................................... 587
 
Improved Deployment .................................................................................................................................................................. 587
 
Support for Client Application Services ..................................................................................................................................... 587
 
Support for Reporting Applications ............................................................................................................................................ 587
 
Exploring a Sample ASP.NET 3.5 Web Application .................................................................................................................... 588
 
Creating a Sample ASP.NET 3.5 Website ....................................................................................................................................... 590
 
Summary ............................................................................................................................................................................................. 594
 
Quick Revise ....................................................................................................................................................................................... 594
Chapter 15: Developing a Web Application ............................................................................... 597
Specifying a Location for a Web Application ................................................................................................................................ 598
 
File System ....................................................................................................................................................................................... 598
 
HTTP ................................................................................................................................................................................................ 599
 
Table of Contents
xvi
Storing Web Applications Using the FTP Site Option ............................................................................................................. 602
 
File Types in ASP.NET 3.5 ................................................................................................................................................................ 603
 
Exploring ASP.NET 3.5 Web Pages ................................................................................................................................................ 605
 
Code Render Blocks ....................................................................................................................................................................... 606
 
Understanding ASP.NET 3.5 Page Directives ............................................................................................................................... 608
 
The @ Page Directive ..................................................................................................................................................................... 608
 
The @ Control Directive ................................................................................................................................................................ 608
 
The @ Import Directive .................................................................................................................................................................. 608
 
The @ Implements Directive ......................................................................................................................................................... 608
 
The @ Register Directive ............................................................................................................................................................... 609
 
The @ Assembly Directive ............................................................................................................................................................ 609
 
The @ Master Directive .................................................................................................................................................................. 609
 
The @ WebHandler Directive ....................................................................................................................................................... 609
 
The @ PreviousPageType Directive ............................................................................................................................................ 609
 
The @ MasterType Directive ........................................................................................................................................................ 609
 
The @ OutputCache Directive ...................................................................................................................................................... 609
 
The @ Reference Directive ............................................................................................................................................................ 610
 
Working with Server Controls ......................................................................................................................................................... 610
 
Understanding ASP.NET 3.5 Provider Model .............................................................................................................................. 612
 
ASP.NET 3.5 Coding Models ........................................................................................................................................................... 613
 
Single-File Page Model .................................................................................................................................................................. 614
 
Code-Behind Page Model ............................................................................................................................................................. 615
 
Implementing Code Sharing ............................................................................................................................................................ 616
 
Using the Code Directory ............................................................................................................................................................. 616
 
Using the bin Directory ................................................................................................................................................................. 617
 
Using the Global Assembly Cache .............................................................................................................................................. 617
 
Compilation in ASP.NET 3.5 ............................................................................................................................................................ 618
 
Compiling on First Request .......................................................................................................................................................... 618
 
Recompiling on Change ................................................................................................................................................................ 618
 
Compilation Dependencies .......................................................................................................................................................... 618
 
Using the Merge Tool .................................................................................................................................................................... 618
 
Summary ............................................................................................................................................................................................. 619
 
Quick Revise ....................................................................................................................................................................................... 619
Chapter 16: Application Structure and State ............................................................................. 621
Structure of an Application .............................................................................................................................................................. 622
 
The Application Domain ............................................................................................................................................................... 622
 
The Application Lifetime .............................................................................................................................................................. 623
 
The Application Directory Structure ........................................................................................................................................... 623
 
The Global.asax Application File..................................................................................................................................................... 624
 
Using States ......................................................................................................................................................................................... 626
 
Application State ............................................................................................................................................................................ 626
 
Session State .................................................................................................................................................................................... 626
 
View State ........................................................................................................................................................................................ 627
 
Using Application State, Session State, and View state ........................................................................................................... 627
 
HTTP Handlers .................................................................................................................................................................................. 629
 
Creating an HTTP Handlers Application ................................................................................................................................... 629
 
Generic Handlers ............................................................................................................................................................................ 630
 
Postback ............................................................................................................................................................................................... 633
 
Cross-Page Posting ......................................................................................................................................................................... 633
 
Summary ............................................................................................................................................................................................. 637
 
Quick Revise ....................................................................................................................................................................................... 637

Chapter 17: Web Forms: Standard Controls ............................................................................. 639
Table of Contents
xvii
The Control Class ............................................................................................................................................................................... 641
 
The WebControl Class ....................................................................................................................................................................... 643
 
Using CSS in Web Applications ...................................................................................................................................................... 644
 
The Label Control .............................................................................................................................................................................. 650
 
Working with Label Controls ....................................................................................................................................................... 651
 
The Button Control ............................................................................................................................................................................ 652
 
Working with Button Controls..................................................................................................................................................... 653
 
The TextBox Control .......................................................................................................................................................................... 654
 
Working with TextBox Controls .................................................................................................................................................. 655
 
The Literal Control ............................................................................................................................................................................. 657
 
Working with Literal Controls ..................................................................................................................................................... 658
 
The PlaceHolder Control .................................................................................................................................................................. 659
 
Working with PlaceHolder Controls .......................................................................................................................................... 660
 
The HiddenField Control.................................................................................................................................................................. 661
 
Working with Hidden Field Controls ......................................................................................................................................... 662
 
The FileUpload Control .................................................................................................................................................................... 663
 
Working with FileUpload Control .............................................................................................................................................. 664
 
The Image Control ............................................................................................................................................................................. 666
 
Working with Image Controls ......................................................................................................................................................... 667
 
The ImageMap Control ..................................................................................................................................................................... 669
 
Working with ImageMap Controls ................................................................................................................................................. 670
 
The ListBox Control ........................................................................................................................................................................... 673
 
Working with ListBox Controls ....................................................................................................................................................... 674
 
The DropDownList Control ............................................................................................................................................................. 678
 
Working with DropDownList Controls ......................................................................................................................................... 679
 
The BulletedList Control ................................................................................................................................................................... 681
 
Working with BulletedList Controls ............................................................................................................................................... 682
 
The HyperLink Control .................................................................................................................................................................... 684
 
Working with HyperLink Controls ................................................................................................................................................ 685
 
The LinkButton Control .................................................................................................................................................................... 686
 
Working with LinkButton Controls ................................................................................................................................................ 687
 
The CheckBox Control ...................................................................................................................................................................... 689
 
Working with CheckBox Controls .................................................................................................................................................. 690
 
The RadioButton Control .................................................................................................................................................................. 692
 
Working with RadioButton Controls .............................................................................................................................................. 693
 
The Table Control .............................................................................................................................................................................. 695
 
Working with Table Controls .......................................................................................................................................................... 696
 
The Wizard Control ........................................................................................................................................................................... 699
 
Working with Wizard Controls ....................................................................................................................................................... 702
 
User Controls and Custom Controls ............................................................................................................................................... 707
 
Working with User Controls ............................................................................................................................................................ 707
 
Working with Custom Controls ...................................................................................................................................................... 709
 
Summary ............................................................................................................................................................................................. 711
 
Quick Revise ....................................................................................................................................................................................... 711
 
Chapter 18: Navigation Controls: TreeView, Menu, and SiteMapPath .................................... 713
Using the TreeView Class ................................................................................................................................................................. 714
 
The TreeView Control ....................................................................................................................................................................... 716
 
Adding Nodes to a TreeView Control Dynamically ................................................................................................................ 717
 
Adding Nodes to a TreeView Control Using the DataSource Property ............................................................................... 717
 
Adding Nodes to a TreeView Control at Design Time ............................................................................................................ 718
 
Creating the TreeView Control ........................................................................................................................................................ 718
 
Generating TreeView from a Database .......................................................................................................................................... 729
 
Using the Menu Class ....................................................................................................................................................................... 733
 
The Menu Control .............................................................................................................................................................................. 736
 
Using the XmlDataSource Class .................................................................................................................................................. 737
 
Table of Contents
xviii
Using the XmlDataSource Control .............................................................................................................................................. 738
 
Menu Display Properties .............................................................................................................................................................. 739
 
Menu Styles ..................................................................................................................................................................................... 739
 
Creating Static Menus ....................................................................................................................................................................... 739
 
Creating Dynamic Menus ................................................................................................................................................................. 741
 
Using the SiteMapPath Class ........................................................................................................................................................... 744
 
The SiteMapPath Control ................................................................................................................................................................. 745
 
Data Retrieval Using the SiteMapPath Control ......................................................................................................................... 746
 
SiteMapPath Behaviors ................................................................................................................................................................. 746
 
SiteMapPath Appearance.............................................................................................................................................................. 747
 
SiteMapPath Style .......................................................................................................................................................................... 747
 
SiteMapPath Templates ................................................................................................................................................................. 747
 
Creating SiteMapPath ....................................................................................................................................................................... 747
 
Summary ............................................................................................................................................................................................. 751
 
Quick Revies ....................................................................................................................................................................................... 751
 
Chapter 19: Validation Controls .................................................................................................. 753
Introduction ........................................................................................................................................................................................ 754
 
The BaseValidator Class ................................................................................................................................................................... 754
 
The RequiredFieldValidator Control .............................................................................................................................................. 755
 
Using the RequiredFieldValidator Control ................................................................................................................................... 755
 
The RangeValidator Control ............................................................................................................................................................ 757
 
Using the RangeValidator Control .................................................................................................................................................. 758
 
The RegularExpressionValidator Control ...................................................................................................................................... 759
 
Using the RegularExpressionValidator Control ........................................................................................................................... 760
 
The CompareValidator Control ....................................................................................................................................................... 762
 
Using the CompareValidator Control ............................................................................................................................................ 763
 
The CustomValidator Control ......................................................................................................................................................... 765
 
Using the CustomValidator Control ............................................................................................................................................... 766
 
The ValidationSummary Control .................................................................................................................................................... 767
 
Using the ValidationSummary Control ......................................................................................................................................... 768
 
Summary ............................................................................................................................................................................................. 770
 
Quick Revise ....................................................................................................................................................................................... 770
Chapter 20: Introducing Web Parts Controls ............................................................................ 771
The WebPartManager Control ......................................................................................................................................................... 772
 
Using the WebPartManager Class .................................................................................................................................................. 782
 
Creating the WebPartManager Control in Code ....................................................................................................................... 782
 
The ProxyWebPartManager Control .............................................................................................................................................. 784
 
The WebPartZone Control................................................................................................................................................................ 785
 
Creating the WebPartZone Control in Code ................................................................................................................................. 788
 
The CatalogZone Control ................................................................................................................................................................. 790
 
Creating the CatalogZone Control in Code ................................................................................................................................... 792
 
The DeclarativeCatalogPart Control ............................................................................................................................................... 794
 
The PageCatalogPart Control .......................................................................................................................................................... 796
 
Creating the PageCatalogPart Control in Code ............................................................................................................................ 797
 
The ImportCatalogPart Control ....................................................................................................................................................... 800
 
The EditorZone Control .................................................................................................................................................................... 801
 
Creating the EditorZone Control in Code ..................................................................................................................................... 804
 
The LayoutEditorPart Control ......................................................................................................................................................... 806
 
The AppearanceEditorPart Control ................................................................................................................................................ 808
 
The PropertyGridEditorPart Control .............................................................................................................................................. 809
 
Creating the PropertyGridEditorPart Control in Code ............................................................................................................... 811
 
The BehaviorEditorPart Control ...................................................................................................................................................... 813
 
The ConnectionsZone Control ......................................................................................................................................................... 814
 
Creating the ConnectionsZone Control in Code .......................................................................................................................... 817
 
Table of Contents
xix
Summary ............................................................................................................................................................................................. 818
 
Quick Revise ....................................................................................................................................................................................... 819
Chapter 21: Working with Database Controls ........................................................................... 821
The GridView Control ....................................................................................................................................................................... 822
 
Using the GridView Control ............................................................................................................................................................ 826
 
The DataList Control ......................................................................................................................................................................... 828
 
Using the DataList Control ............................................................................................................................................................... 830
 
The DetailsView Control .................................................................................................................................................................. 832
 
Using the DetailsView Control ........................................................................................................................................................ 836
 
The FormView Control ..................................................................................................................................................................... 838
 
Using the FormView Control ........................................................................................................................................................... 841
 
The ListView Control ........................................................................................................................................................................ 843
 
The Repeater Control ........................................................................................................................................................................ 847
 
Using the Repeater Control .............................................................................................................................................................. 849
 
The DataPager Control ...................................................................................................................................................................... 851
 
Using the ListView and DataPager Controls ................................................................................................................................ 853
 
The SqlDataSource Control .............................................................................................................................................................. 857
 
Using the SqlDataSource Control .................................................................................................................................................... 860
 
The AccessDataSource Control ........................................................................................................................................................ 865
 
Using the AccessDataSource Control ............................................................................................................................................. 867
 
The LinqDataSource Control ........................................................................................................................................................... 870
 
Using the LinqDataSource Control ................................................................................................................................................. 874
 
The ObjectDataSource Control ........................................................................................................................................................ 877
 
Using the ObjectDataSource Control .............................................................................................................................................. 880
 
The XmlDataSource Control ............................................................................................................................................................ 884
 
Using the XmlDataSource Control .................................................................................................................................................. 886
 
The SiteMapDataSource Control ..................................................................................................................................................... 888
 
Summary ............................................................................................................................................................................................. 890
 
Quick Revise ....................................................................................................................................................................................... 890
Chapter 22: Introducing Login Controls .................................................................................... 893
Introducing the Membership Service ............................................................................................................................................. 894
 
The Login Control .............................................................................................................................................................................. 895
 
The LoginView Control .................................................................................................................................................................... 897
 
The LoginStatus Control ................................................................................................................................................................... 898
 
The LoginName Control ................................................................................................................................................................... 900
 
The PasswordRecovery Control ...................................................................................................................................................... 900
 
The CreateUserWizard Control ....................................................................................................................................................... 903
 
The ChangePassword Control ......................................................................................................................................................... 907
 
Implementing Authentication in ASP.NET Using Login Controls ........................................................................................... 911
 
Summary ............................................................................................................................................................................................. 918
 
Quick Revise ....................................................................................................................................................................................... 918
Chapter 23: Inside Master Pages and Themes .......................................................................... 921
Need for Master Pages and Themes ............................................................................................................................................... 922
 
Understanding Master Pages ........................................................................................................................................................... 922
 
Simple Master Page ........................................................................................................................................................................ 923
 
Creating Master Pages ...................................................................................................................................................................... 923
 
Simple Master Pages ...................................................................................................................................................................... 923
 
Nested Master Pages ...................................................................................................................................................................... 927
 
Creating Nested Master Pages ..................................................................................................................................................... 927
 
Configuring Master Pages ................................................................................................................................................................ 928
 
Modifying Content on the Master Page from the Content Page ................................................................................................ 929
 
Displaying Properties and Methods Using a Master Page ......................................................................................................... 931
 
Loading Pages Dynamically ............................................................................................................................................................. 933
 
Table of Contents
xx
Understanding ASP.NET AJAX Master Pages.............................................................................................................................. 936
 
Understanding Themes ..................................................................................................................................................................... 936
 
Types of Themes in ASP.NET 3.5 ................................................................................................................................................ 937
 
Creating Themes ................................................................................................................................................................................ 937
 
Applying Themes at Control and Runtime Levels ....................................................................................................................... 939
 
Applying Themes to a Single Page ................................................................................................................................................. 942
 
Understanding the StyleSheetTheme Attribute ........................................................................................................................ 944
 
Using the StyleSheetTheme Attribute ............................................................................................................................................ 944
Summary ............................................................................................................................................................................................. 945
 
Quick Revise ....................................................................................................................................................................................... 945
 
Chapter 24: Managing Web Applications ................................................................................... 947
Need to Manage Applications ......................................................................................................................................................... 948
 
The ASP.NET Configuration File .................................................................................................................................................... 948
 
Verifying the Configuration Settings .............................................................................................................................................. 949
 
The Process Model Configuration ................................................................................................................................................... 951
 
Reactive Process Recycling ........................................................................................................................................................... 952
 
Proactive Process Recycling .......................................................................................................................................................... 952
 
The ASP.NET MMC Snap-In Tool .................................................................................................................................................. 952
 
The ASPNET_REGIIS Tool ............................................................................................................................................................... 953
 
Using the ASPNET_REGIIS Tool .................................................................................................................................................... 954
 
Using the ProtectSection Method .................................................................................................................................................... 955
 
The Web Site Administration Tool .................................................................................................................................................. 957
 
Using the Web Site Administration Tool ....................................................................................................................................... 957
 
Using the Security Tab................................................................................................................................................................... 958
 
Using the Application Tab ............................................................................................................................................................ 962
 
Using the Provider Tab ................................................................................................................................................................. 965
 
The Aspnet_regsql Tool .................................................................................................................................................................... 965
 
Using the Aspnet_regsql Tool .......................................................................................................................................................... 966
 
Configuring ASP.NET Applications in IIS .................................................................................................................................... 967
 
Summary ............................................................................................................................................................................................. 969
 
Quick Revise ....................................................................................................................................................................................... 969
Chapter 25: Application Globalization ....................................................................................... 971
Globalization ....................................................................................................................................................................................... 972
 
Internationalization ........................................................................................................................................................................ 974
 
Localization ..................................................................................................................................................................................... 975
 
Listing the Available Cultures ......................................................................................................................................................... 975
 
Working with Resources ................................................................................................................................................................... 977
 
Working with Local Resources .................................................................................................................................................... 977
 
Working with Global Resources .................................................................................................................................................. 978
 
Using Localization Expression ......................................................................................................................................................... 979
 
Implicit Expression ........................................................................................................................................................................ 979
 
Explicit Expression ......................................................................................................................................................................... 993
 
Performing Localization ................................................................................................................................................................. 1004
 
Elements of HTML ....................................................................................................................................................................... 1005
 
Static Content ................................................................................................................................................................................ 1005
 
Localizing Script Files ..................................................................................................................................................................... 1012
 
Deploying Resources ....................................................................................................................................................................... 1015
 
Summary ........................................................................................................................................................................................... 1015
 
Quick Revise ..................................................................................................................................................................................... 1015
Chapter 26: Developing Rich-Interactive Applications with Silverlight ................................ 1017
Improved Programming Model ................................................................................................................................................. 1018
 
Comprehensive UI Framework ................................................................................................................................................. 1019
 
Support for Deep Zoom Technology ........................................................................................................................................ 1019
 
Table of Contents
xxi
Support for 2-D Graphics, Animations, and Multimedia ...................................................................................................... 1019
 
Support for Networking .............................................................................................................................................................. 1019
 
The .NET Framework for Silverlight ......................................................................................................................................... 1020
 
The Core Presentation Framework ............................................................................................................................................ 1020
 
Controls in Silverlight Applications .......................................................................................................................................... 1032
 
Using the DatePicker Control ..................................................................................................................................................... 1036
 
Using the GridSplitter Control ................................................................................................................................................... 1039
 
Using the MediaPlayer Control to Embed Media ................................................................................................................... 1041
 
ASP.NET Server Controls for Silverlight ................................................................................................................................. 1044
 
Using the Silverlight Control ...................................................................................................................................................... 1046
 
Using the MediaElement Control .............................................................................................................................................. 1049
PART 5: CREATING XML APPLICATION
Chapter 27: Working with XML .................................................................................................. 1053
Introduction to XML ........................................................................................................................................................................ 1054
 
XML Basics ........................................................................................................................................................................................ 1054
 
XML Syntax ................................................................................................................................................................................... 1055
 
XML Declaration .......................................................................................................................................................................... 1055
 
XML Elements ............................................................................................................................................................................... 1056
 
XML Attributes ............................................................................................................................................................................. 1057
 
Valid XML Documents ................................................................................................................................................................ 1058
 
Viewing XML ................................................................................................................................................................................ 1058
 
XML Parser .................................................................................................................................................................................... 1060
 
Document Type Definition ......................................................................................................................................................... 1062
 
Parameter Entities and Conditional Sections .......................................................................................................................... 1067
 
Advanced XML ................................................................................................................................................................................ 1069
 
XML Namespaces ......................................................................................................................................................................... 1069
 
XML CDATA ................................................................................................................................................................................ 1073
 
XML Encoding .............................................................................................................................................................................. 1074
 
XML on the Server ....................................................................................................................................................................... 1075
 
XML Application .......................................................................................................................................................................... 1075
 
XMLHttpRequest Object ............................................................................................................................................................. 1077
 
XML Technologies ........................................................................................................................................................................... 1077
 
Extensible HTML (XHTML) ........................................................................................................................................................... 1077
 
Converting HTML to XML ......................................................................................................................................................... 1078
 
Java API for XML Processing ......................................................................................................................................................... 1079
 
The JAXP APIs .............................................................................................................................................................................. 1080
 
An Overview of the Packages .................................................................................................................................................... 1080
 
Document Object Model (DOM) ................................................................................................................................................... 1080
 
Parsing XML Documents Using DOM ..................................................................................................................................... 1082
 
Simple API for XML (SAX) ............................................................................................................................................................. 1085
 
Parsing XML Documents Using SAX ........................................................................................................................................ 1087
 
Extensible Stylesheet Language Transformation (XSLT) .......................................................................................................... 1090
 
XSLT Stylesheet ............................................................................................................................................................................ 1092
 
XSLT Functions ............................................................................................................................................................................. 1101
 
Transforming an XML Document Using XSLT ........................................................................................................................... 1106
 
XPath .................................................................................................................................................................................................. 1109
 
Functionality of XPath ................................................................................................................................................................. 1110
 
XPath Functions ............................................................................................................................................................................ 1111
 
XML Linking Mechanism ............................................................................................................................................................... 1128
 
Linking with XLink and XPointer ............................................................................................................................................. 1128
 
Working with XLink ........................................................................................................................................................................ 1129
 
Working with XPointer ................................................................................................................................................................... 1130
 

Summary ........................................................................................................................................................................................... 1130
 
Table of Contents
xxii
Quick Revise ..................................................................................................................................................................................... 1130
 
PART 6: CREATING AJAX APPLICATIONS
Chapter 28: AJAX: A New Approach ........................................................................................ 1135
Evolution of Web Application ....................................................................................................................................................... 1136
 
Common Gateway Interface (CGI) ............................................................................................................................................ 1136
 
Applets ........................................................................................................................................................................................... 1137
 
JavaScript ....................................................................................................................................................................................... 1137
 
Servlets ........................................................................................................................................................................................... 1138
 
JavaServer Pages (JSP) ................................................................................................................................................................. 1138
 
Active Server Pages (ASP) .......................................................................................................................................................... 1139
 
PHP ................................................................................................................................................................................................. 1139
 
Dynamic HTML (DHTML) ......................................................................................................................................................... 1139
 
XML ................................................................................................................................................................................................ 1140
 
Problems with Technologies ...................................................................................................................................................... 1142
 
AJAX—The Solution .................................................................................................................................................................... 1143
 
Creating A Sample AJAX Application ...................................................................................................................................... 1145
 
Creating the XMLHttpRequest Object ...................................................................................................................................... 1147
 
Opening XMLHttpRequest Object for Asynchronous Downloads ..................................................................................... 1148
 
Summary ........................................................................................................................................................................................... 1150
 
Quick Revise ..................................................................................................................................................................................... 1150
Chapter 29: Understanding JavaScript for AJAX .................................................................... 1153
Introduction to JavaScript ............................................................................................................................................................... 1154
 
Basics of JavaScript ....................................................................................................................................................................... 1156
 
What is Document Object Model? ................................................................................................................................................. 1169
 
Methods Available in DOM for Accessing Objects ................................................................................................................ 1171
 
DOM Levels................................................................................................................................................................................... 1172
 
Creating a JavaScript Application without AJAX ...................................................................................................................... 1176
 
JavaScript and AJAX........................................................................................................................................................................ 1178
 
Creating a JavaScript Application with AJAX ............................................................................................................................ 1179
 
Summary ........................................................................................................................................................................................... 1182
 
Quick Revise ..................................................................................................................................................................................... 1182
Chapter 30: Asynchronous data transfer with XMLHttpRequest .......................................... 1185
XMLHttpRequest Object ................................................................................................................................................................. 1186
 
Synchronous and Asynchronous Pages ................................................................................................................................... 1187
 
XMLHttpRequest Properties ...................................................................................................................................................... 1188
 
XMLHttpRequest Methods ......................................................................................................................................................... 1191
 
Browser Differences ......................................................................................................................................................................... 1192
 
Reading a File Synchronously........................................................................................................................................................ 1193
 
Reading a File Asynchronously ..................................................................................................................................................... 1196
 
Using Basic AJAX Techniques ....................................................................................................................................................... 1198
 
Performing Validation ................................................................................................................................................................. 1198
 
Reading Response Headers ........................................................................................................................................................ 1202
 
Loading Dynamically List Boxes ............................................................................................................................................... 1204
 
Auto Refreshing Page .................................................................................................................................................................. 1208
 
Dynamic Progress Bar ................................................................................................................................................................. 1211
 
Providing Auto Complete ........................................................................................................................................................... 1215
 
XMLHttpRequest Object Vs IFrames ............................................................................................................................................ 1220
 
Using IFrames ................................................................................................................................................................................... 1221
 
Summary ........................................................................................................................................................................................... 1222
 
Quick Revise ..................................................................................................................................................................................... 1223
Chapter 31: Implementing AJAX Frameworks ........................................................................ 1225
Table of Contents
xxiii
Working with Jquery Framework ................................................................................................................................................. 1226
 
Working with Prototype Framework ........................................................................................................................................... 1230
 
Working with Script.aculo.us Framework ................................................................................................................................... 1233
 
Working with Dojo Toolkit Framework ....................................................................................................................................... 1234
 
Working with DWR Framework ................................................................................................................................................... 1241
 
Working with JPSpan Framework ................................................................................................................................................ 1242
 
Working with Rico Framework ..................................................................................................................................................... 1244
 
Working with Spry Framework..................................................................................................................................................... 1250
 
Commonly used frameworks for AJAX ....................................................................................................................................... 1256
 
Yahoo UI Library .......................................................................................................................................................................... 1256
 
Google Web Toolkit ..................................................................................................................................................................... 1256
 
AJAX.NET Professional ............................................................................................................................................................... 1256
 
Summary ........................................................................................................................................................................................... 1257
 
Quick Revise ..................................................................................................................................................................................... 1257
Chapter 32: Developing ASP.NET AJAX Applications ........................................................... 1259
AJAX—A New Approach ............................................................................................................................................................... 1260
Exploring JavaScript .................................................................................................................................................................... 1260
 
Introducing XHTML .................................................................................................................................................................... 1261
 
Introducing CSS ............................................................................................................................................................................ 1261
 
Exploring DOM ............................................................................................................................................................................ 1261
 
Introducing XMLHttpRequest Object ....................................................................................................................................... 1262
 
Need for AJAX ................................................................................................................................................................................. 1263
AJAX and Other Technologies ....................................................................................................................................................... 1263
ASP.NET AJAX Architecture ......................................................................................................................................................... 1264
Client-Side Architecture .............................................................................................................................................................. 1264
 
Server-Side Architecture ............................................................................................................................................................. 1266
 
AJAX Server or Extension Controls .............................................................................................................................................. 1267
The ScriptManager Control ........................................................................................................................................................ 1267
 
Differentiating Between AJAX and Non-AJAX Applications .................................................................................................. 1270
Creating a Simple non-AJAX Application ............................................................................................................................... 1270
 
Creating a simple AJAX Application ........................................................................................................................................ 1272
 
The ScriptManagerProxy Control .............................................................................................................................................. 1274
 
The Timer Control ........................................................................................................................................................................ 1274
 
The UpdatePanel Control ........................................................................................................................................................... 1275
 
Using AJAX Server Controls .......................................................................................................................................................... 1276
Timer Control ................................................................................................................................................................................ 1276
The UpdateProgress Control ...................................................................................................................................................... 1278
 
UpdateProgress Control .............................................................................................................................................................. 1279
 
Using AlwaysVisibleControlExtender ...................................................................................................................................... 1289
 
ASP.NET AJAX Control Toolkit Extenders and Controls ........................................................................................................ 1282
Installing the ASP.NET AJAX Control Toolkit ........................................................................................................................... 1286
Using the ASP.NET AJAX Control Toolkit .................................................................................................................................. 1289
Summary ........................................................................................................................................................................................... 1292
Quick Revise ..................................................................................................................................................................................... 1292
Chapter 33: Integrating PHP and AJAX .................................................................................... 1295
Introducing PHP .............................................................................................................................................................................. 1296
 
Building Blocks ............................................................................................................................................................................. 1296
 
Installing PHP Server ...................................................................................................................................................................... 1299
 
Sending Data to Server .................................................................................................................................................................... 1299
 
AJAX-PHP Frameworks ................................................................................................................................................................. 1300
 
Performing Validation .................................................................................................................................................................... 1302
 
Polling Application .......................................................................................................................................................................... 1304
 
Suggestions Application ................................................................................................................................................................. 1307
 
Handling XML Data using PHP and AJAX ................................................................................................................................. 1310
 
Table of Contents
xxiv
Fetching Records from Database using AJAX ............................................................................................................................. 1314
 
Summary ........................................................................................................................................................................................... 1317
 
Quick Revise ..................................................................................................................................................................................... 1317
 
Chapter 34: Consuming Web Services in AJAX ...................................................................... 1319
Web Services Technologies ............................................................................................................................................................ 1320
 
SOAP .................................................................................................................................................................................................. 1320
 
SOAP Message .............................................................................................................................................................................. 1320
 
SOAP Message Elements ............................................................................................................................................................ 1321
 
SOAP Example .............................................................................................................................................................................. 1323
 
WSDL ................................................................................................................................................................................................. 1324
 
UDDI .................................................................................................................................................................................................. 1327
 
REST ................................................................................................................................................................................................... 1327
 
REST Web Services Characteristics ........................................................................................................................................... 1328
 
Elements of REST Architecture .................................................................................................................................................. 1329
 
Rules of REST Web Service Design ........................................................................................................................................... 1331
 
REST Views ................................................................................................................................................................................... 1331
 
Design Decisions .............................................................................................................................................................................. 1332
 
Service Interaction Layer Design ............................................................................................................................................... 1333
 
Processing Layer Design ............................................................................................................................................................. 1336
 
Other Technologies .......................................................................................................................................................................... 1336
 
Java API for XML based RPC (JAX-RPC) ................................................................................................................................. 1336
 
Java Architecture for XML Binding (JAXB) ............................................................................................................................. 1337
 
Java API for XML Messaging (JAXM) ...................................................................................................................................... 1337
 
Java API for XML Registries (JAXR) ......................................................................................................................................... 1337
 
Java API for XML Parsing ........................................................................................................................................................... 1337
 
Creating a Web Service ................................................................................................................................................................ 1338
 
Invoking a Web Service ............................................................................................................................................................... 1341
 
Cross Domain Web Services .......................................................................................................................................................... 1342
 
Using APIs ........................................................................................................................................................................................ 1343
 
javax.xml ........................................................................................................................................................................................ 1343
 
javax.xml.bind ............................................................................................................................................................................... 1343
 
javax.xml.datatype ....................................................................................................................................................................... 1343
 
javax.xml.registry ......................................................................................................................................................................... 1344
 
javax.xml.rpc ................................................................................................................................................................................. 1344
 
javax.xml.soap ............................................................................................................................................................................... 1344
 
javax.xml.transform ..................................................................................................................................................................... 1345
 
javax.xml.validation ..................................................................................................................................................................... 1345
 
Summary ........................................................................................................................................................................................... 1346
 
Quick Revise ..................................................................................................................................................................................... 1346
Appendix A .................................................................................................................................. 1349
Appendix B .................................................................................................................................. 1357
Appendix C .................................................................................................................................. 1369
Index ............................................................................................................................................ 1377
About the CD ............................................................................................................................... 1382