100% found this document useful (21 votes)
290 views

Core Web Programming Volumes I II Includes index 2nd ed Edition Hall download pdf

Volumes

Uploaded by

goziumlilo25
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (21 votes)
290 views

Core Web Programming Volumes I II Includes index 2nd ed Edition Hall download pdf

Volumes

Uploaded by

goziumlilo25
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 85

Download the full version of the ebook at ebookfinal.

com

Core Web Programming Volumes I II Includes index


2nd ed Edition Hall

https://ebookfinal.com/download/core-web-programming-
volumes-i-ii-includes-index-2nd-ed-edition-hall/

OR CLICK BUTTON

DOWNLOAD EBOOK

Download more ebook instantly today at https://ebookfinal.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

DB2 developer s guide Includes index 5th ed Edition


Mullins

https://ebookfinal.com/download/db2-developer-s-guide-includes-
index-5th-ed-edition-mullins/

ebookfinal.com

McGraw Hill s PRAXIS I and II 2nd Ed 2nd Edition Laurie


Rozakis

https://ebookfinal.com/download/mcgraw-hill-s-praxis-i-and-ii-2nd-
ed-2nd-edition-laurie-rozakis/

ebookfinal.com

Core Servlets and Javaserver Pages Advanced Technologies


2nd Edition Marty Hall

https://ebookfinal.com/download/core-servlets-and-javaserver-pages-
advanced-technologies-2nd-edition-marty-hall/

ebookfinal.com

Web Programming with Dart 1st ed. Edition Moises Belchin

https://ebookfinal.com/download/web-programming-with-dart-1st-ed-
edition-moises-belchin/

ebookfinal.com
Joomla 1 5 a user s guide building a successful Joomla
powered website Description based on print version record
Includes index 2nd ed Edition North
https://ebookfinal.com/download/joomla-1-5-a-user-s-guide-building-a-
successful-joomla-powered-website-description-based-on-print-version-
record-includes-index-2nd-ed-edition-north/
ebookfinal.com

Programming Microsoft ASP NET 2 0 Core Reference 2005 ed


Edition Dino Esposito

https://ebookfinal.com/download/programming-microsoft-asp-
net-2-0-core-reference-2005-ed-edition-dino-esposito/

ebookfinal.com

World of Warcraft Programming 2nd Edition James Whitehead


Ii

https://ebookfinal.com/download/world-of-warcraft-programming-2nd-
edition-james-whitehead-ii/

ebookfinal.com

80X86 IBM PC and Compatible Computers Assembly Language


Design and Interfacing Volumes I II 4th Edition Muhammad
Ali Mazidi
https://ebookfinal.com/download/80x86-ibm-pc-and-compatible-computers-
assembly-language-design-and-interfacing-volumes-i-ii-4th-edition-
muhammad-ali-mazidi/
ebookfinal.com

Murach s ASP NET 4 Web programming with C 2010 4th ed


Edition Boehm

https://ebookfinal.com/download/murach-s-asp-net-4-web-programming-
with-c-2010-4th-ed-edition-boehm/

ebookfinal.com
CORE
Web Programming

MARTY HALL
LARRY BROWN

Prentice Hall PTR


Upper Saddle River, NJ 07458
www.phptr.com
Library of Congress Cataloging-in-Publication Data
Hall, Marty.
Core web programming / Marty Hall, Larry Brown.
p. cm.
Only Marty Hall’s name appears on previous edition.
Includes index.
ISBN 0-13-089793-0
1. Internet programming. 2. HTML (Document markup language) 3. Java (Computer
program language) 4. CGI (Computer network protocol) 5. World Wide Web. I. Hall,
Marty. II. Title.
QA76.625 .B757 2001
005.2'76--dc21
2001021692
© 2001 Sun Microsystems, Inc.—
Printed in the United States of America.
901 San Antonio Road, Palo Alto, California
94303-4900 U.S.A.
All rights reserved. This product and related documentation are protected by copyright and
distributed under licenses restricting its use, copying, distribution, and decompilation. No part
of this product or related documentation may be reproduced in any form by any means without
prior written authorization of Sun and its licensors, if any.
RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the United States
Government is subject to the restrictions set forth in DFARS 252.227-7013 (c)(1)(ii) and
FAR 52.227-19.
The products described may be protected by one or more U.S. patents, foreign patents, or
pending applications.
TRADEMARKS—HotJava, Java, Java Development Kit, Solaris, SPARC, SunOS, and Sunsoft
are trademarks of Sun Microsystems, Inc. All other products or services mentioned in this book
are the trademarks or service marks of their respective companies or organizations
The publisher offers discounts on this book when ordered in bulk quantities.
For more information, contact Corporate Sales Department, Prentice Hall PTR ,
One Lake Street, Upper Saddle River, NJ 07458. Phone: 800-382-3419; FAX: 201- 236-7141.
E-mail: corpsales@prenhall.com.

Production Editor and Compositor: Vanessa Moore


Project Coordinator: Anne Trowbridge
Acquisitions Editor: Gregory G. Doench
Editorial Assistant: Brandt Kenna
Cover Design Director: Jerry Votta
Cover Designer: Nina Scuderi
Cover Illustration: Karen Strelecki
Art Director: Gail Cocker-Bogusz
Manufacturing Manager: Alexis R. Heydt
Marketing Manager: Debby vanDijk
Sun Microsystems Press:
Marketing manager: Michael Llwyd Alread
Publisher: Rachel Borden

10 9 8 7 6 5 4 3 2 1

ISBN 0-13-089793-0

Sun Microsystems Press


A Prentice Hall Title
Chapter

INTRODUCTION XXXIII
Real Code for Real Programmers xxxiv
How This Book Is Organized xxxv
Conventions xxxviii
About the Web Site xxxix
About the Authors xxxix

ACKNOWLEDGMENTS XLI

Part 1
THE HYPERTEXT MARKUP LANGUAGE 2

C hap t er 1
DESIGNING WEB PAGES WITH HTML 4.0 4
1.1 The HyperText Markup Language 5
1.2 HTML 4.0 and Other HTML Standards 7
1.3 Steps to Publish a Document on the Web 9
Create the Document 9

iii
iv Contents

Put the Document on the Web 10


Validate the Document 12
1.4 The Basic Structure of HTML Documents 12
HTML Document Template 13
DOCTYPE Declarations 14
1.5 HEAD—High-Level Information About the Page 16
Required HEAD Element 17
Optional HEAD Elements 17
1.6 BODY—Creating the Main Document 22
1.7 Summary 25

ChapTer 2
BLOCK-LEVEL ELEMENTS IN HTML 4.0 28
2.1 Headings 30
2.2 Basic Text Elements 32
Basic Paragraphs 32
Paragraphs with White Space Preserved 34
Indented Quotations 35
Addresses 35
2.3 Numbered, Bulleted, and Indented Lists 35
Numbered Lists 36
Bulleted Lists 39
Definition Lists 40
2.4 Tables 41
The Basic Table Structure 42
Defining Table Rows 46
Table Headings and Data Cells 48
Grouping Table Contents 50
2.5 Fill-Out Forms 54
2.6 Miscellaneous Block-Level Elements 54
2.7 Summary 57
Contents v

ChapTer 3
TEXT-LEVEL ELEMENTS IN HTML 4.0 58
3.1 Physical Character Styles 59
3.2 Logical Character Styles 64
3.3 Specifying Hypertext Links 67
3.4 Embedded Images 70
Animated GIFs 71
The IMG Element 71
3.5 Client-Side Image Maps 75
3.6 Embedding Other Objects in Documents 79
Embedded Applets 80
Embedded Video, Audio, and Other Formats with Plug-ins 82
Embedded ActiveX Controls 83
Embedded Scrolling Text Banners 85
3.7 Controlling Line Breaks 86
3.8 Summary 87

Chapter 4
FRAMES 88
4.1 Frame Document Template 90
4.2 Specifying Frame Layout 91
4.3 Specifying the Content of Frame Cells 96
Examples 98
4.4 Targeting Frame Cells 100
Predefined Frame Names 103
4.5 Solving Common Frame Problems 103
Bookmarking Frames 104
Printing Frames 104
Updating Multiple Frame Cells Simultaneously 105
Preventing Your Documents from Being Framed 108
Creating Empty Frame Cells 109
4.6 Inline Frames 109
4.7 Summary 113
vi Contents

Chapter 5
CASCADING STYLE SHEETS 114
5.1 Specifying Style Rules 116
5.2 Using External and Local Style Sheets 118
External Style Sheets 119
The STYLE Element and JavaScript Style Sheets 120
Inline Style Specification 121
5.3 Selectors 121
HTML Elements 122
User-Defined Classes 123
User-Defined IDs 124
Anchor Pseudoclasses 124
5.4 Cascading: Style Sheet Precedence Rules 125
5.5 Font Properties 126
5.6 Foreground and Background Properties 132
5.7 Text Properties 135
5.8 Properties of the Bounding Box 139
Margins 140
Borders 141
Padding 142
Bounding Box Display Types 143
5.9 Images and Floating Elements 143
5.10 List Properties 146
5.11 Standard Property Units 147
Lengths 147
Colors 147
5.12 Layers 148
Specifying Layers with the LAYER and ILAYER Elements 149
Specifying Layers with Style Sheets 153
5.13 Summary 157
Contents vii

Part 2
JAVA PROGRAMMING 158

Chapter 6
GETTING STARTED WITH JAVA 160
6.1 Unique Features of Java 162
Java Is Web-Enabled and Network Savvy 162
Java Is Cross-Platform 166
Java Is Simple 168
Java Is Object Oriented 169
Java Is Rich with Powerful Standard Libraries 170
6.2 Myths About Java 171
Java Is Only for the Web 172
Java Is Cross-Platform 172
Java Is Simple 174
Java Is Object Oriented (the One True Way of Programming) 174
Java Is the Programming Language for All Software Development 175
6.3 Java Versions 175
Which Version Should You Use? 177
Whichever Version You Use 177
6.4 Getting Started: Nuts and Bolts 178
Install Java 178
Install a Java-Enabled Browser 179
Bookmark or Install the On-Line Java API 180
Optional: Get an Integrated Development Environment 180
Create and Run a Java Program 181
6.5 Some Simple Java Programs 182
The Basic Hello World Application 182
Command-Line Arguments 183
The Basic Hello World (Wide Web) Applet 183
Applet Customization Parameters 185
6.6 Summary 187
viii Contents

Chapter 7
OBJECT-ORIENTED PROGRAMMING IN JAVA 190
7.1 Instance Variables 191
7.2 Methods 194
7.3 Constructors and the “this” Reference 196
Static Initialization Blocks 199
7.4 Destructors 199
7.5 Overloading 200
7.6 Public Version in Separate File 204
7.7 Javadoc 209
Javadoc Tags 211
Javadoc Command-Line Arguments 213
7.8 Inheritance 216
7.9 Interfaces and Abstract Classes 221
7.10 Packages, Classpath, and JAR Archives 230
The CLASSPATH 233
7.11 Modifiers in Declarations 236
Visibility Modifiers 236
Other Modifiers 238
7.12 Summary 239

Chapter 8
BASIC JAVA SYNTAX 242
8.1 Rules of Syntax 243
8.2 Primitive Types 245
Primitive-Type Conversion 247
8.3 Operators, Conditionals, Iteration 248
Arithmetic Operators 248
Conditionals 249
Loops 255
8.4 The Math Class 259
Constants 259
Contents ix

General-Purpose Methods 259


Trigonometric Methods 261
BigInteger and BigDecimal 261
8.5 Input and Output 263
Printing to Standard Output 263
Printing to Standard Error 265
Reading from Standard Input 265
8.6 Execution of Non-Java Programs 266
8.7 Reference Types 273
Java Argument-Passing Conventions 275
The instanceof Operator 275
8.8 Strings 277
String Methods 278
Constructors 284
8.9 Arrays 284
Two-Step Array Allocation 285
One-Step Array Allocation 286
Multidimensional Arrays 287
8.10 Vectors 288
Constructors 289
Methods 289
8.11 Example: A Simple Binary Tree 291
8.12 Exceptions 296
Basic Form 296
Multiple Catch Clauses 299
The Finally Clause 300
Thrown Exceptions 300
Unchecked Exceptions 302
8.13 Summary 303
x Contents

Chapter 9
APPLETS AND BASIC GRAPHICS 304
9.1 What Are Applets? 305
9.2 Creating an Applet 306
Template for Applets 307
Template for HTML 307
9.3 An Example Applet 309
Redrawing Automatically 311
Reloading Applets During Development 311
9.4 The Applet Life Cycle 312
9.5 Other Applet Methods 314
9.6 The HTML APPLET Element 320
9.7 Reading Applet Parameters 322
Reading Applet Parameters: An Example 323
9.8 HTML OBJECT Element 326
9.9 The Java Plug-In 328
9.10 Graphical Applications 331
9.11 Graphics Operations 332
Drawing Operations 333
Colors and Fonts 336
Drawing Modes 336
Coordinates and Clipping Rectangles 337
9.12 Drawing Images 337
Loading Applet Images from Relative URLs 338
Loading Applet Images from Absolute URLs 340
Loading Images in Applications 342
9.13 Preloading Images 344
9.14 Controlling Image Loading: Waiting for Images and Checking
Status 348
9.15 Summary 355
Contents xi

Chapter 10
JAVA 2D: GRAPHICS IN JAVA 2 358
10.1 Getting Started with Java 2D 360
Useful Graphics2D Methods 363
10.2 Drawing Shapes 366
Shape Classes 367
10.3 Paint Styles 371
Paint Classes 372
Tiled Images as Fill Patterns 375
10.4 Transparent Drawing 378
10.5 Using Local Fonts 381
10.6 Stroke Styles 383
Stroke Attributes 384
10.7 Coordinate Transformations 390
Shear Transformations 393
10.8 Other Capabilities of Java 2D 394
10.9 Summary 395

Chapter 11
HANDLING MOUSE AND KEYBOARD EVENTS 398
11.1 Handling Events with a Separate Listener 400
Drawing Circles 402
11.2 Handling Events by Implementing a Listener Interface 404
11.3 Handling Events with Named Inner Classes 406
11.4 Handling Events with Anonymous Inner Classes 407
11.5 The Standard Event Listeners 409
11.6 Behind the Scenes: Low-Level Event Processing 415
11.7 A Spelling-Correcting Textfield 418
11.8 A Whiteboard Class 421
A Better Whiteboard 423
11.9 Summary 425
xii Contents

Chapter 12
LAYOUT MANAGERS 426
12.1 The FlowLayout Manager 428
FlowLayout Constructor Options 429
Other FlowLayout Methods 429
12.2 The BorderLayout Manager 430
BorderLayout Constructor Options 432
Other BorderLayout Methods 432
12.3 The GridLayout Manager 433
GridLayout Constructor Options 434
Other GridLayout Methods 435
12.4 The CardLayout Manager 436
CardLayout Constructor Options 440
Other CardLayout Methods 440
12.5 GridBagLayout 441
The GridBagConstraints Object 442
Example 444
GridBagLayout Constructor Options 448
Other GridBagLayout Methods 448
12.6 The BoxLayout Manager 449
BoxLayout Constructor Options 452
Other BoxLayout Methods 453
12.7 Turning Off the Layout Manager 454
12.8 Effective Use of Layout Managers 455
Use Nested Containers 456
Turn Off the Layout Manager for Some Containers 459
Adjust the Empty Space Around Components 461
12.9 Summary 464
Contents xiii

Chapter 13
AWT COMPONENTS 466
13.1 The Canvas Class 468
Creating and Using a Canvas 469
Example: A Circle Component 469
13.2 The Component Class 472
13.3 Lightweight Components in Java 1.1 479
13.4 The Panel Class 482
Default LayoutManager: FlowLayout 482
Creating and Using a Panel 483
Example: Using a Panel for Grouping 483
13.5 The Container Class 485
13.6 The Applet Class 487
13.7 The ScrollPane Class 487
Creating and Using a ScrollPane 487
Example: ScrollPane with 100-Button Panel 488
13.8 The Frame Class 489
Default LayoutManager: BorderLayout 489
Creating and Using a Frame 490
Frame Examples 491
A Closeable Frame 492
Menus 493
Other Useful Frame Methods 495
13.9 Serializing Windows 497
Writing a Window to Disk 497
Reading a Window from Disk 497
Example: A Saveable Frame 498
13.10 The Dialog Class 501
Creating and Using a Dialog 501
Example: A Quit Confirmation Dialog 502
13.11 The FileDialog Class 504
xiv Contents

Example: Displaying Files in a TextArea 504


13.12 The Window Class 507
Default LayoutManager: BorderLayout 507
Creating and Using a Window 507
13.13 Handling Events in GUI Controls 508
Decentralized Event Processing 509
Centralized Event Processing 511
13.14 The Button Class 512
Constructors 513
Example: Applet with Three Buttons 513
Other Button Methods 514
Handling Button Events 515
13.15 The Checkbox Class 518
Constructors 519
Example: Checked Checkboxes 519
Other Checkbox Methods 520
Handling Checkbox Events 521
13.16 Check Box Groups (Radio Buttons) 521
Constructors 522
Example: Check Boxes vs. Radio Buttons 522
Other CheckboxGroup and Checkbox Methods 523
Handling CheckboxGroup Events 524
13.17 Choice Menus 524
Constructor 525
Example: Simple Choices 525
Other Choice Methods 526
Handling Choice Events 527
13.18 List Boxes 529
Constructors 529
Example: Single and Multiple List Selections 529
Other List Methods 531
Handling List Events 533
Contents xv

13.19 The TextField Class 538


Constructors 538
Example: Creating TextFields 539
Other TextField Methods 539
Handling TextField Events 542
13.20 The TextArea Class 543
Constructors 543
Example: Empty and Filled Text Areas 544
Other TextArea Methods 544
Handling TextArea Events 545
13.21 The Label Class 545
Constructors 546
Example: Four Different Labels 546
Other Label Methods 547
Handling Label Events 548
13.22 Scrollbars and Sliders 550
Constructors 550
Example: Variety of Sliders 551
Other Scrollbar Methods 552
Handling Scrollbar Events 554
13.23 Pop-up Menus 556
Constructors 556
Example: Applet Pop-up Menu 556
Other PopupMenu Methods 558
Handling PopupMenu Events 559
13.24 Summary 560

Chapter 14
BASIC SWING 562
14.1 Getting Started with Swing 564
Differences Between Swing and the AWT 564
xvi Contents

14.2 The JApplet Component 572


14.3 The JFrame Component 574
14.4 The JLabel Component 576
New Features: Images, Borders, and HTML Content 576
JLabel Constructors 577
Useful JLabel Methods 578
14.5 The JButton Component 581
New Features: Icons, Alignment, and Mnemonics 581
HTML in Button Labels 582
JButton Constructors 582
Useful JButton (AbstractButton) Methods 582
14.6 The JPanel Component 585
JPanel Constructors 585
New Feature: Borders 585
Useful BorderFactory Methods 586
14.7 The JSlider Component 590
New Features: Tick Marks and Labels 590
JSlider Constructors 590
Useful JSlider Methods 591
14.8 The JColorChooser Component 594
Constructors 595
Useful JColorChooser Methods 595
14.9 Internal Frames 598
JInternalFrame Constructors 598
Useful JInternalFrame Methods 598
14.10 The JOptionPane Component 602
Useful JOptionPane Methods 602
14.11 The JToolBar Component 607
JToolBar Constructors 609
Useful JToolBar Methods 609
14.12 The JEditorPane Component 614
Following Hypertext Links 615
Contents xvii

JEditorPane Constructors 616


Useful JEditorPane Methods 616
Implementing a Simple Web Browser 618
HTML Support and JavaHelp 621
14.13 Other Simple Swing Components 622
The JCheckBox Component 622
The JRadioButton Component 623
The JTextField Component 625
The JTextArea Component 625
The JFileChooser Component 625
14.14 Summary 626

Chapter 15
ADVANCED SWING 628
15.1 Using Custom Data Models and Renderers 630
15.2 JList 631
JList with a Fixed Set of Choices 631
JLists with Changeable Choices 636
JList with Custom Data Model 639
JList with Custom Renderer 646
15.3 JTree 650
Simple JTree 650
JTree Event Handling 654
15.4 JTable 664
Simple JTable 664
Table Data Models 669
Table Cell Renderers 674
Table Event Handling 676
15.5 Swing Component Printing 680
Printing Basics 681
The Role of Double Buffering 683
xviii Contents

A General-Purpose Component-Printing Routine 684


Printing in JDK 1.3 689
15.6 Swing Threads 691
SwingUtilities Methods 693
15.7 Summary 696

Chapter 16
CONCURRENT PROGRAMMING WITH JAVA THREADS 698
16.1 Starting Threads 700
Mechanism 1: Put Behavior in a Separate Thread Object 700
Mechanism 2: Put Behavior in the Driver Class,
Which Must Implement Runnable 703
16.2 Race Conditions 706
16.3 Synchronization 709
Synchronizing a Section of Code 709
Synchronizing an Entire Method 710
Common Synchronization Bug 710
16.4 Creating a Multithreaded Method 712
16.5 Thread Methods 717
Constructors 718
Constants 719
Methods 719
Stopping a Thread 725
16.6 Thread Groups 727
Constructors 727
Methods 727
16.7 Multithreaded Graphics and Double Buffering 729
Redraw Everything in paint 730
Implement the Dynamic Part as a Separate Component 734
Have Routines Other Than paint Draw Directly 735
Override update and Have paint Do Incremental Updating 737
Use Double Buffering 743
Contents xix

16.8 Animating Images 748


16.9 Timers 753
Constructor 757
Other Timer Methods 757
16.10 Summary 759

Chapter 17
NETWORK PROGRAMMING 760
17.1 Implementing a Client 762
Example: A Generic Network Client 765
17.2 Parsing Strings by Using StringTokenizer 768
The StringTokenizer Class 768
Constructors 769
Methods 769
Example: Interactive Tokenizer 770
17.3 Example: A Client to Verify E-Mail Addresses 771
17.4 Example: A Network Client That Retrieves URLs 774
A Class to Retrieve a Given URI from a Given Host 775
A Class to Retrieve a Given URL 777
UrlRetriever Output 778
17.5 The URL Class 779
Reading from a URL 779
Other Useful Methods of the URL Class 781
17.6 WebClient: Talking to Web Servers Interactively 783
17.7 Implementing a Server 791
Example: A Generic Network Server 793
Connecting NetworkClient and NetworkServer 797
17.8 Example: A Simple HTTP Server 797
ThreadedEchoServer: Adding Multithreading 802
17.9 RMI: Remote Method Invocation 804
Steps to Build an RMI Application 805
A Simple Example 806
xx Contents

A Realistic Example: A Server for Numeric Integration 811


A Realistic Example of the Four Required Classes 813
Compiling and Running the System for the Realistic Example 817
Enterprise RMI Configuration 819
Compiling and Running the System for an
Enterprise RMI Configuration 822
RMI Applet Example 825
17.10 Summary 828

Par t 3
SERVER-SIDE PROGRAMMING 830

Chapter 18
HTML FORMS 832
18.1 How HTML Forms Transmit Data 833
18.2 The FORM Element 838
18.3 Text Controls 843
Textfields 843
Password Fields 845
Text Areas 846
18.4 Push Buttons 848
Submit Buttons 849
Reset Buttons 852
JavaScript Buttons 853
18.5 Check Boxes and Radio Buttons 854
Check Boxes 854
Radio Buttons 855
18.6 Combo Boxes and List Boxes 857
18.7 File Upload Controls 860
18.8 Server-Side Image Maps 862
IMAGE—Standard Server-Side Image Maps 863
ISMAP—Alternative Server-Side Image Maps 865
Contents xxi

18.9 Hidden Fields 867


18.10 Grouping Controls 868
18.11 Tab Order Control 870
18.12 Summary 871

Chapter 19
SERVER-SIDE JAVA: SERVLETS 872
19.1 The Advantages of Servlets Over “Traditional” CGI 874
Efficient 874
Convenient 875
Powerful 875
Portable 875
Secure 876
Inexpensive 876
19.2 Server Installation and Setup 876
Obtain Servlet and JSP Software 877
Bookmark or Install the Servlet and JSP API Documentation 878
Identify the Classes to the Java Compiler 878
Package Your Classes 879
Configure the Server 879
Compile and Install Your Servlets 879
Invoke Your Servlets 880
19.3 Basic Servlet Structure 880
A Servlet That Generates Plain Text 882
A Servlet That Generates HTML 883
Simple HTML-Building Utilities 885
19.4 The Servlet Life Cycle 887
The init Method 887
The service Method 888
The doGet, doPost, and doXxx Methods 889
The SingleThreadModel Interface 889
xxii Contents

The destroy Method 890


19.5 An Example Using Initialization Parameters 890
19.6 The Client Request: Form Data 893
Reading Form Data from CGI Programs 893
Reading Form Data from Servlets 894
Example: Reading Three Explicit Parameters 894
Filtering Query Data 897
19.7 The Client Request: HTTP Request Headers 898
Reading Request Headers from Servlets 899
Example: Making a Table of All Request Headers 900
HTTP 1.1 Request Headers 903
Sending Compressed Web Pages 906
19.8 The Servlet Equivalent of the Standard CGI Variables 908
19.9 The Server Response: HTTP Status Codes 911
Specifying Status Codes 912
HTTP 1.1 Status Codes 913
A Front End to Various Search Engines 919
19.10 The Server Response: HTTP Response Headers 924
Setting Response Headers from Servlets 924
HTTP 1.1 Response Headers 926
Persistent Servlet State and Auto-Reloading Pages 932
19.11 Cookies 941
Benefits of Cookies 942
Some Problems with Cookies 943
The Servlet Cookie API 944
Examples of Setting and Reading Cookies 947
Basic Cookie Utilities 951
Finding Cookies with Specified Names 951
Creating Long-Lived Cookies 953
19.12 Session Tracking 953
The Need for Session Tracking 953
Contents xxiii

The Session Tracking API 955


Terminating Sessions 959
A Servlet Showing Per-Client Access Counts 960
19.13 Summary 962

Chapter 20
JAVASERVER PAGES 964
20.1 JSP Overview 965
20.2 Advantages of JSP 967
Versus Active Server Pages (ASP) or ColdFusion 967
Versus PHP 967
Versus Pure Servlets 967
Versus Server-Side Includes (SSI) 968
Versus JavaScript 968
20.3 JSP Scripting Elements 968
Expressions 969
Scriptlets 972
Declarations 975
Predefined Variables 977
20.4 The JSP page Directive 979
The import Attribute 979
The contentType Attribute 982
The isThreadSafe Attribute 983
The session Attribute 984
The buffer Attribute 984
The autoflush Attribute 984
The extends Attribute 985
The info Attribute 985
The errorPage Attribute 985
The isErrorPage Attribute 985
The language Attribute 985
xxiv Contents

XML Syntax for Directives 986


20.5 Including Files and Applets in JSP Documents 986
The include Directive: Including Files at Page Translation Time 987
Including Files at Request Time 989
Including Applets for the Java Plug-In 992
The jsp:fallback Element 995
20.6 Using JavaBeans with JSP 999
Basic Bean Use 1001
Example: StringBean 1003
Setting Bean Properties 1005
Sharing Beans 1011
20.7 Defining Custom JSP Tags 1015
The Components That Make Up a Tag Library 1015
Defining a Basic Tag 1019
Assigning Attributes to Tags 1022
Including the Tag Body 1026
Optionally Including the Tag Body 1031
Manipulating the Tag Body 1034
Including or Manipulating the Tag Body Multiple Times 1038
Using Nested Tags 1042
20.8 Integrating Servlets and JSP 1049
Forwarding Requests 1049
Example: An On-Line Travel Agent 1053
Forwarding Requests From JSP Pages 1062
20.9 Summary 1062

Chapter 21
USING APPLETS AS FRONT ENDS TO
SERVER-SIDE PROGRAMS 1064
21.1 Sending Data with GET and Displaying the Resultant Page 1066
21.2 A Multisystem Search Engine Front End 1067
Contents xxv

21.3 Using GET and Processing the Results Directly


(HTTP Tunneling) 1071
Reading Binary or ASCII Data 1072
Reading Serialized Data Structures 1073
21.4 A Query Viewer That Uses Object Serialization
and HTTP Tunneling 1075
21.5 Using POST and Processing the Results Directly
(HTTP Tunneling) 1083
21.6 An Applet That Sends POST Data 1086
21.7 Bypassing the HTTP Server 1091
21.8 Summary 1091

Chapter 22
JDBC 1092
22.1 Basic Steps in Using JDBC 1094
Load the Driver 1094
Define the Connection URL 1095
Establish the Connection 1096
Create a Statement 1096
Execute a Query 1097
Process the Results 1097
Close the Connection 1098
22.2 Basic JDBC Example 1098
22.3 Some JDBC Utilities 1105
22.4 Applying the Database Utilities 1114
22.5 An Interactive Query Viewer 1120
Query Viewer Code 1122
22.6 Prepared Statements (Precompiled Queries) 1127
22.7 Summary 1131
xxvi Contents

Chapter 23
XML PROCESSING WITH JAVA 1132
23.1 Parsing XML Documents with DOM Level 2 1134
Installation and Setup 1134
Parsing 1135
23.2 DOM Example: Representing an XML Document as a JTree 1137
23.3 Parsing XML Documents with SAX 2.0 1149
Installation and Setup 1149
Parsing 1150
23.4 SAX Example 1: Printing the Outline of an XML Document 1152
23.5 SAX Example 2: Counting Book Orders 1158
23.6 Transforming XML with XSLT 1164
Installation and Setup 1164
Translating 1165
23.7 XSLT Example 1: XSLT Document Editor 1169
23.8 XSLT Example 2: Custom JSP Tag 1179
23.9 Summary 1187

Par t 4
JAVASCRIPT 1188

Chapter 24
JAVASCRIPT: ADDING DYNAMIC CONTENT TO WEB PAGES 1190
24.1 Generating HTML Dynamically 1193
Compatibility with Multiple Browsers 1197
24.2 Monitoring User Events 1198
24.3 Mastering JavaScript Syntax 1200
Dynamic Typing 1201
Function Declarations 1201
Objects and Classes 1202
Arrays 1208
Contents xxvii

24.4 Using JavaScript to Customize Web Pages 1209


Adjusting to the Browser Window Size 1209
Determining Whether Plug-Ins Are Available 1213
24.5 Using JavaScript to Make Pages Dynamic 1215
Modifying Images Dynamically 1215
Moving Layers 1223
24.6 Using JavaScript to Validate HTML Forms 1228
Checking Values Individually 1229
Checking Values When Form Is Submitted 1231
24.7 Using JavaScript to Store and Examine Cookies 1237
24.8 Using JavaScript to Interact with Frames 1242
Directing a Particular Frame to Display a URL 1242
Giving a Frame the Input Focus 1246
24.9 Accessing Java from JavaScript 1246
Calling Java Methods Directly 1247
Using Applets to Perform Operations for JavaScript 1248
Controlling Applets from JavaScript 1252
24.10 Accessing JavaScript from Java 1256
Example: Matching Applet Background with Web Page 1259
Example: An Applet That Controls HTML Form Values 1260
Methods in the JSObject Class 1271
24.11 Summary 1272

Chapter 25
JAVASCRIPT QUICK REFERENCE 1274
25.1 The Array Object 1275
Constructors 1275
Properties 1276
Methods 1276
Event Handlers 1279
xxviii Contents

25.2 The Button Object 1279


Properties 1279
Methods 1280
Event Handlers 1280
25.3 The Checkbox Object 1281
Properties 1281
Methods 1282
Event Handlers 1282
25.4 The Date Object 1283
Constructors 1283
Properties 1283
Methods 1283
Event Handlers 1286
25.5 The Document Object 1286
Properties 1286
Methods 1288
Event Handlers 1289
25.6 The Element Object 1289
Properties 1289
Methods 1290
Event Handlers 1291
25.7 The FileUpload Object 1291
Properties 1292
Methods 1292
Event Handlers 1292
25.8 The Form Object 1293
Properties 1293
Methods 1293
Event Handlers 1294
25.9 The Function Object 1294
Constructor 1294
Contents xxix

Properties 1295
Methods 1295
Event Handlers 1295
25.10 The Hidden Object 1296
Properties 1296
Methods 1296
Event Handlers 1296
25.11 The History Object 1296
Properties 1297
Methods 1297
Event Handlers 1297
25.12 The Image Object 1297
Constructor 1298
Properties 1298
Methods 1299
Event Handlers 1299
25.13 The JavaObject Object 1300
25.14 The JavaPackage Object 1300
25.15 The Layer Object 1300
Constructors 1300
Properties 1301
Methods 1302
Event Handlers 1303
25.16 The Link Object 1304
Properties 1304
Methods 1305
Event Handlers 1305
25.17 The Location Object 1306
Properties 1306
Methods 1307
Event Handlers 1307
xxx Contents

25.18 The Math Object 1307


Properties 1307
Methods 1308
Event Handlers 1310
25.19 The MimeType Object 1310
Properties 1311
Methods 1311
Event Handlers 1311
25.20 The Navigator Object 1311
Properties 1311
Methods 1314
Event Handlers 1314
25.21 The Number Object 1314
Constructor 1315
Properties 1315
Methods 1315
Event Handlers 1317
25.22 The Object Object 1317
Constructors 1318
Properties 1318
Methods 1318
Event Handlers 1319
25.23 The Option Object 1319
Constructors 1319
Properties 1319
Methods 1320
Event Handlers 1320
25.24 The Password Object 1320
Properties 1320
Methods 1321
Event Handlers 1321
Contents xxxi

25.25 The Plugin Object 1322


Properties 1322
Methods 1322
Event Handlers 1322
25.26 The Radio Object 1323
Properties 1323
Methods 1323
Event Handlers 1324
25.27 The RegExp Object 1324
Constructors 1324
Properties 1326
Methods 1327
Event Handlers 1328
Special Patterns in Regular Expressions 1328
25.28 The Reset Object 1329
Properties 1330
Methods 1330
Event Handlers 1330
25.29 The Screen Object 1331
Properties 1331
Methods 1332
Event Handlers 1332
25.30 The Select Object 1332
Properties 1333
Methods 1334
Event Handlers 1334
25.31 The String Object 1335
Constructor 1335
Properties 1335
Methods 1335
Event Handlers 1340
xxxii Contents

25.32 The Submit Object 1340


Properties 1340
Methods 1341
Event Handlers 1341
25.33 The Text Object 1342
Properties 1342
Methods 1342
Event Handlers 1343
25.34 The Textarea Object 1343
Properties 1344
Methods 1344
Event Handlers 1344
25.35 The Window Object 1345
Properties 1345
Methods 1349
Event Handlers 1354
An Example of the open Method 1355
25.36 Summary 1358

INDEX 1360
Chapter

In late 1995, Marty Hall proposed a new course for the part-time graduate program
in Computer Science at the Johns Hopkins University. The idea was to bring together
the major Web-related topics in a single course dubbed “Distributed Development
on the World Wide Web,” with Java technology as a unifying theme. Students would
look at HTML, Java, HTTP, CGI programming, and JavaScript, with lots of hands-on
projects and no exams. Little did Marty know what he was getting himself into. By
the time the first section was offered in the summer of 1996, the Java tidal wave had
swept through the university and the companies that the students represented.
Shortly after enrollment opened, the class was filled. There were more students on
the waiting list than in the course. Marty got frantic phone calls from students insist-
ing that they absolutely had to be in the course. Several local companies called, ask-
ing for on-site courses. What fun!
However, when Marty went shopping for texts over the next semester or two, he
got a rude surprise. Despite the availability of good books in most of the individual
areas he wanted to cover, Marty found that he needed three, four, or even five sepa-
rate books to get good coverage of the overall material. Similarly, for his day job,
Marty was constantly switching back and forth among the best of the huge stack of
books he had accumulated and various on-line references. Surely there was a better
way. Shouldn’t it be possible to fit 85 percent of what professional programmers use
in about 35 percent of the space, and get it all in one book?
That was the genesis of the first edition of Core Web Programming. The book was
very popular, but the industry has been rapidly moving since the book’s release.
Browsers moved from HTML 3.2 to 4.0. The Java 2 platform was released, providing
greatly improved performance and graphics libraries suitable for commercial-quality

xxxiii
xxxiv Introduction

applications. JSP 1.0 came along, resulting in an explosion of interest in both servlets
and JSP as an alternative to CGI and to proprietary solutions like ASP and Cold-
Fusion. XML burst upon the scene. The server equalled or even surpassed the desk-
top as the biggest application area for the Java programming language.
Wow. And demand has only been growing since then. Although readers were
clamoring for a new edition of the book, it was just too much for Marty to handle
alone. Enter Larry Brown, with broad development and teaching experience in Java
and Web technologies, and with particular expertise in the Java Foundation Classes,
multithreaded programming, RMI, and XML processing with Java. Larry teamed up
with Marty to totally update the existing material to HTML 4, CSS/1, HTTP 1.1, and
the Java 2 platform; to replace the CGI sections with chapters on servlets 2.2 and JSP
1.1; and to add completely new sections on Swing, Java 2D, and XML processing
with JAXP, DOM Level 2, SAX 2.0, and XSLT. They even got a little bit of sleep along
the way.
We—Marty and Larry—hope you find the result enjoyable and useful!

Real Code for Real Programmers

This book is aimed at serious software developers. If you are looking for a book that
shows you how to use a browser, lists the current hottest Web sites, and pontificates
about how Web-enabled applications will revolutionize your business, you’ve come to
the wrong place. If you’re already a programmer of some sort and want to get started
with HTML, XML, Java applets, desktop applications in Java, servlets, JavaServer
Pages, and JavaScript as quickly as possible, this is the book for you. We illustrate the
most important approaches and warn you of the most common pitfalls. To do so, we
include plenty of working code: over 250 complete Java classes, for instance. We try
to give detailed examples of the most important and frequently used features, sum-
marize the lesser-used ones, and refer you to the API (available on-line) for a few of
the rarely used ones.

DILBERT © UFS. Reprinted by permission.


Introduction xxxv

A word of caution, however. Nobody becomes a great developer just by reading.


You have to write some real code too. The more, the better. In each chapter, we sug-
gest that you start by making a simple program or a small variation of one of the
examples given, then strike off on your own with a more significant project. Skim the
sections you don’t plan on using right away, then come back when you are ready to try
them out.
If you do this, you should quickly develop the confidence to handle the real-world
problems that brought you here in the first place. You should be able to balance the
demand for the latest features in Web pages with the need for multiplatform support.
You should be comfortable with frames, style sheets, and layered HTML. You should
be able to make portable stand-alone graphical applications. You should have no
qualms about developing Web interfaces to your corporate database through JDBC.
You should be able to connect these applications to remote systems over the network.
You should understand how to easily distribute computation among multiple threads,
or even spin it off to separate systems by using RMI. You should be able to decide
where servlets apply well, where JSP is better, and where a combination is best. You
should understand HTTP 1.1 well enough to use its capabilities to enhance the effec-
tiveness of your pages. You should be able to spin off complex server-side behaviors
into JavaBeans components or custom JSP tag libraries. You should be able to use
JavaScript to validate HTML forms or to animate Web pages. You should get a raise.
A big one, preferably.

How This Book Is Organized

This book is divided into four parts: HTML, Java programming, server-side program-
ming, and JavaScript.

Part 1: The HyperText Markup Language


Web pages are created with HTML, the HyperText Markup Language. HTML
lets you mix regular text with special tags that describe the content, layout, or
appearance of the text. These tags are then used by Web browsers like
Netscape Navigator or Microsoft Internet Explorer to format the page. This
first part of the book covers the following topics in HTML.

• HTML 4.01. Full coverage of all the elements in the latest official
HTML standard. Hypertext links, fonts, images, tables, client-side
image maps, and more.
• Major Netscape and Internet Explorer extensions. Forwarding
pages, using custom colors and font faces, embedding audio, video,
and ActiveX components.
xxxvi Introduction

• Frames. Dividing the screen into rectangular regions, each associated


with a separate HTML document. Borderless frames. Floating
frames. Targeting frame cells from hypertext links.
• Cascading style sheets. Level-one style sheets for customizing fonts,
colors, images, text formatting, indentation, lists, and more.

Part 2: Java Programming


Java is a powerful general-purpose programming language that can be used to
create stand-alone programs as well as ones that are embedded in Web pages.
The following Java topics are covered.

• Unique features of Java. What’s different about Java? The truth


about Java myths and hype.
• Object-oriented programming in Java. Variables, methods,
constructors, overloading, and interfaces. Modifiers in class
declarations. Packages, the CLASSPATH, and JAR files.
• Java syntax. Primitive types, operators, strings, vectors, arrays, input/
output and the Math class.
• Graphics. Applets. Applications. Drawing, color, font, and clipping
area operations. Loading and drawing images. Java Plug-In.
• Java 2D. Creating professional, high-quality 2D graphics. Creating
custom shapes, tiling images, using local fonts, creating transparent
shapes, and transforming coordinates.
• Mouse and keyboard events. Processing events. Event types, event
listeners, and low-level event handlers. Inner classes. Anonymous
classes.
• Layout managers. FlowLayout, BorderLayout, GridLayout,
CardLayout, GridBagLayout, and BoxLayout. Positioning
components by hand. Strategies for using layout managers effectively.
• AWT components. Canvas, Panel, Applet, ScrollPane,
Frame, Dialog, FileDialog, and Window. Component and
Container. Buttons, check boxes, radio buttons, combo boxes, list
boxes, textfields, text areas, labels, scrollbars, and pop-up menus.
Saving and loading windows with object serialization.
• Basic Swing components. Building Swing applets and applications.
Changing the GUI look and feel. Adding custom borders to
components. Using HTML in labels and buttons. Sending dialog
alerts for user input. Adding child frames to applications. Building
custom toolbars. Implementing a Web browser in Swing.
• Advanced Swing. JList, JTree, and JTable. Using custom data
models and renderers. Printing Swing components. Updating Swing
components in a thread-safe manner.
Introduction xxxvii

• Multithreaded programming. Threads in separate or existing


objects. Synchronizing access to shared resources. Grouping threads.
Multithreaded graphics and double buffering. Animating images.
Controlling timers.
• Network programming. Clients and servers using sockets. The URL
class. Implementing a generic network server. Creating a simple
HTTP server. Invoking distributed objects with RMI.

Part 3: Server-Side Programming


Programs that run on a Web server can generate dynamic content based on
client data. Servlets are Java technology’s answer to CGI programming and JSP
is Java’s answer to Active Server Pages or ColdFusion. The following server-
side topics are discussed.

• HTML forms. Sending data from forms. Text controls. Push buttons.
Check boxes and radio buttons. Combo boxes and list boxes. File
upload controls. Server-side image maps. Hidden fields. Tab ordering.
• Java servlets. The advantages of servlets over competing
technologies. Servlet life cycle. Servlet initialization parameters.
Accessing form data. Using HTTP 1.1 request headers, response
headers, and status codes. Using cookies in servlets. Session tracking.
• JavaServer Pages (JSP). The benefits of JSP. JSP expressions,
scriptlets, and declarations. Using JavaBeans components with JSP.
Creating custom JSP tag libraries. Combining servlets and JSP.
• Using applets as servlet front ends. Sending GET and POST data.
HTTP tunneling. Using object serialization to exchange high-level
data structures between applets and servlets. Bypassing the HTTP
server altogether.
• Java Database Connectivity (JDBC). The seven basic steps in
connecting to databases. Some utilities that simplify JDBC usage.
Formatting a database result as plain text or HTML. An interactive
graphical query viewer. Precompiled queries.
• XML processing with Java. Representing an entire XML document
by using the Document Object Model (DOM) Level 2. Responding to
individual XML parsing events with the Simple API for XML Parsing
(SAX) 2.0. Transforming XML with XSLT. Hiding vendor-specific
details with the Java API for XML Processing (JAXP).

Part 4: JavaScript
JavaScript is a scripting language that can be embedded in Web pages and
interpreted as the pages are loaded. The final part covers the following Java-
Script topics.
xxxviii Introduction

• JavaScript syntax. Fields, methods, functions, strings, objects,


arrays, and regular expressions.
• Customizing Web pages. Adapting to different browsers, JavaScript
releases, and screen sizes.
• Making pages dynamic. Animating images. Manipulating layers.
Responding to user events.
• Validating HTML forms. Checking form entries as they are
changed. Checking data when form is submitted.
• Handling cookies. Reading and setting values. The Cookie object.
• Controlling frames. Sending results to specific frames. Preventing
documents from being framed. Updating multiple frame cells. Giving
frame cells the focus automatically.
• Integrating Java and JavaScript. LiveConnect and the
JSObject class.
• JavaScript quick reference. Major classes in JavaScript 1.2. All
fields, methods, and event handlers. Document, Window, Form,
Element, String, Math, RegExp, and so forth.

Conventions
Throughout the book, concrete programming constructs or program output is pre-
sented in a monospaced font. For example, when abstractly describing Java programs
that can be embedded in Web pages, we refer to “applets,” but when we refer to
Applet we are talking about the specific Java class from which all applets are
derived.
User input is indicated in boldface, and command-line prompts are either generic
(Prompt>) or indicate the operating system to which they apply (Unix>). For
instance, the following indicates that “Some Output” is the result when “java
SomeProgram” is executed.
Prompt> java SomeProgram
Some Output
Important standard techniques are indicated by specially marked entries, as in the
following example.

Core Approach

Pay particular attention to items in “Core Approach” sections. They indicate


techniques that should always or almost always be used.

Notes and warnings are called out in a similar manner.


Introduction xxxix

About the Web Site

The book has a companion Web site at


http://www.corewebprogramming.com/
This free site includes:

• Documented source code for all examples shown in the book; this
code can be downloaded for unrestricted use.
• On-line versions of all HTML pages, Java applets, and JavaScript
examples.
• Links to all URLs mentioned in the text of the book.
• Information on book discounts.
• Reports on Java short courses.
• Book additions, updates, and news.
• A free Ronco combination paring knife and e-commerce tool. OK,
maybe not.

About the Authors

Marty Hall is a Senior Computer Scientist in the Research and Technology Develop-
ment Center at the Johns Hopkins University Applied Physics Lab, where he special-
izes in the application of Java and Web technology to customer problems. He also
teaches Java and Web programming in the Johns Hopkins part-time graduate pro-
gram in Computer Science, where he directs the Distributed Computing and Web
Technology concentration areas. When he gets a chance, he also teaches industry
short courses on servlets, JavaServer Pages, and other Java technology areas. He is
the author of Core Servlets and JavaServer Pages and the first edition of Core Web
Programming. Marty can be reached at the following address:

Research and Technology Development Center


The Johns Hopkins University Applied Physics Laboratory
11100 Johns Hopkins Road
Laurel, MD 20723
hall@corewebprogramming.com

Larry Brown is a Senior Network Engineer at the Naval Surface Warfare Center,
Carderock Division, where he specializes in developing and deploying network and
Web solutions in an enterprise environment. He is also a Computer Science faculty
member at the Johns Hopkins University, where he teaches server-side program-
xl Introduction

ming, distributed Web programming, and Java user interface development for the
part-time graduate program in Computer Science. Larry can be reached at the fol-
lowing address:

Naval Surface Warfare Center, Carderock Division


9500 MacArthur Boulevard
West Bethesda, MD 20817
brown@corewebprogramming.com
Many people have helped us out with this book. Without their assistance, we would
still be on the fourth chapter. Those that provided valuable technical feedback,
pointed out errors, and gave useful suggestions include Don Aldridge, Chris Ben-
nett, Camille Bell, Pete Clark, Maria Dimalanta, Nguyen-Khoa Duy, Denise Evans,
Amy Karlson, Paul McNamee, Toddi Norum, Walter Pasquinni, Rich Slywczak, Bob
Tinker, and Kim Topley. This book would not be a success without their contribu-
tions. Mary Lou “Eagle Eye” Nohr spotted our errant commas, awkward sentences,
typographical errors, and grammatical inconsistencies. She improved the result
immensely. We hope that we learned from her advice. Vanessa Moore produced the
final version; she did a great job despite our last-minute changes and crazy travel
schedules. Ralph Semmel and Julie Wessel both provided supportive work environ-
ments and flexible schedules. Greg Doench of Prentice Hall believed in a second
edition and encouraged us to write the book. Thanks to all.
Most of all, I–Marty–thank B.J., Lindsay, and Nathan for their patience with my
long hours and funny schedule. I–Larry–thank Lee for her loving support and
patience while I disappeared to the computer room every weekend.
God has blessed us both with great families.

xli
This page intentionally left blank
1
THE HYPERTEXT
MARKUP LANGUAGE
Chapter 1 Designing Web Pages with HTML 4.0, 4
Chapter 2 Block-Level Elements in HTML 4.0, 28
Chapter 3 Text-Level Elements in HTML 4.0, 58
Chapter 4 Frames, 88
Chapter 5 Cascading Style Sheets, 114
Designing Web
Pages with
Chapter

HTML 4.0

Topics in This Chapter

• An overview of the HyperText Markup Language

• Comparison of HTML 4.0 with other HTML specifications

• Validation of HTML documents

• The process of creating and publishing a Web page

• The fundamental structure of HTML documents

• Common elements in the header of an HTML document

• Inclusion of keyword information for search engines

• Use of the BODY tag to set up the basic look of the page
This page intentionally left blank
Chapter

1
T
his is the first of five chapters that cover the HyperText Markup Language
(HTML). Together, they teach you the techniques for creating professional
Web pages. This first chapter examines the underlying structure of an
HTML document, and the remaining four chapters cover additional topics for build-
ing quality Web pages, including block-level elements, text-level elements, frames,
and cascading style sheets. Once you’ve learned these basics, the remainder of Core
Web Programming covers advanced topics like Java applets, sockets, database con-
nectivity, Java servlets, JavaServer Pages (JSP), and processing XML. All of these
technologies are critical in developing quality Web sites.
The history of the HyperText Markup Language is briefly covered in this chapter,
followed by the steps necessary to create and publish a WWW page. We then focus
on the general structure of Web pages, describe which HTML elements are required
in all documents, and explain how to specify settings that affect the document as a
whole. In addition, we show you how to validate your Web page as legal HTML and
how to record information in your Web page for use by search engines.

1.1 The HyperText Markup Language


Web pages are created with the HyperText Markup Language, which lets you mix
regular text with “markup” tags describing the text. These tags can describe the
appearance (display this in red) or layout (arrange the following in a 3-row, 4-column
table) of the text, but the majority simply describe the content (this is a main head-

5
6 Chapter 1 Designing Web Pages with HTML 4.0

ing) and leave many of the appearance and layout decisions to the browser. For
example, Listing 1.1 shows the HTML document used to create the Web page shown
in Figure 1–1. For now, don’t worry about the details of each of the HTML elements;
they are discussed in detail in the rest of Part 1 of this book. However, even at first
glance you can pick out some basic features, such as the mix of regular text and ele-
ments enclosed in angle brackets and that some but not all the elements come in
pairs of the form <NAME> and </NAME>.
The Web page shown in Figure 1–1 is the result for a particular browser (Internet
Explorer 5.0) on a particular operating system (Windows 2000 Professional) with the
browser and desktop preferences (font face, size, and color) set by the user. In addi-
tion to honoring user customizations, browsers usually have wide latitude in how they
implement the various types of elements, and authors who try to enforce an exact
appearance for pages that will be viewed by multiple browsers often end up frus-
trated. In Chapter 5 (Cascading Style Sheets), you will see a new standard that gives
authors a high degree of control over the final look of their pages. But even with style
sheets, authors of general Web pages should realize that they cannot control all
aspects of the final appearance of their page.

Listing 1.1 An HTML document for a simple home page


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<Title>Home Page for Lawrence M. Brown</Title>
</HEAD>
<BODY BGCOLOR="WHITE">
<H1 ALIGN="CENTER">Home Page for Lawrence M. Brown</H1>
<HR>
<IMG SRC="images/navsea-nswc.gif" WIDTH=300 HEIGHT=117
HSPACE=10 VSPACE=5 ALIGN="LEFT" ALT="NSWC Logo">
Senior Network Engineer<BR>
<A HREF="http://www.dt.navy.mil/">
Naval Surface Warfare Center</A><BR>
9500 MacArthor Boulevard<BR>
West Bethesda, Maryland, MD 20817-5700<BR>
<I>email:</I> <A HREF="mailto:larry@corewebprogramming.com">
larry@corewebprogramming.com</A><BR>
<I>Phone:</I> (301) 277-4648<BR CLEAR="ALL">
<P>
This is my personal home page. For more specific
programming-related resources pages, please see:
<!-- Rest of Sample Page Deleted -->
</BODY>
</HTML>
1.2 HTML 4.0 and Other HTML Standards 7

Figure 1–1 This page, rendered in Internet Explorer 5.0 on Windows 2000
Professional, is the result of the document in Listing 1.1.

Core Note

Trying to enforce an exact look for pages that will be viewed by people using
a variety of browsers will only lead to frustration.

The page design issue is further complicated because Web browsers are not the
only type of programs that use HTML documents. A variety of applications can display,
print, index, or even synthesize speech based on an HTML document. In this book,
however, we concentrate on how HTML documents are used by WWW browsers.

1.2 HTML 4.0 and Other


HTML Standards

Along with browser issues, to a lesser degree, authors must also contend with
changes in the HTML specification. Until January 1997, HTML 2.0, introduced by
the World Wide Web Consortium (W3C), was the most up-to-date standard avail-
able. The HTML 2.0 specification describes the capabilities supported by most
Exploring the Variety of Random
Documents with Different Content
Shanghai dialect, °Zaung-°he °thoo-bak 上海土白.
A Buddhist priest, ih kuh oo-zaung° 一個和尙.
A Taoist priest, ih kuh dau°-z 一個道士.
A nun, ih kuh nyi-koo 一個尼姑.
Number, soo°-mak 數目.

Tsang (張) is the classifier used for sheets of things.

A newspaper, ih tsang sing-vung-°ts 一張新聞紙.


A proclamation, ih tsang kau°-z° 一張告示.
A sheet of paper, ih tsang °ts-deu 一張紙頭.

Pau (包) is the classifier used for bales of things.

A bale of merchandize, ih pau hoo°-suh 一包貨色.

Te (堆) is the classifier used for piles of things.

A pile of timber, ih te mok-deu 一堆木頭.


A pile of bricks, ih te lok-tsen 一堆䃙磚.

°Kwen (管) is the classifier for tubular things.

A flute, ih °kwen dih 一管笛.


A pen, ih °kwen pih 一管筆.
A pencil, ih °kwen khan-pih 一管鉛筆.
Green, lok 綠.
Red, ‘oong 紅.
Blue, lan 藍.
Yellow, waung 黃.
Black, huh 黑.
Few, °sau 少.
Truly, zeh-°dze 實在.
More than, ’veh °ba 勿罷. More than a hundred men is ’veh
°ba ih pak nyung 勿罷一百人.
Less than, ’veh siau 勿消, or ’veh °men 勿滿.
A small quantity of, °tien (used after the verb) 點.
People, pak-sing° 百姓.
Tea, dzo 茶.
Tea leaf, dzo-yih 茶葉.
The whole of a thing, ih tshih 一切.
A man or two, koen-°po-nyung 干把人.
About (used with a number), °po 把.
About a hundred, pak °po 百把.
Nearly, mau 毛.
Nearly three miles, mau san °li-loo° 毛三里路.
A queue, ih diau °bien-°ts 一條辮子.
Hair on the head, deu-fah 頭髪.
News, sing°-sih 信息.
To take things by force, °tsiang 搶, or °tsiang doeh 搶奪.
To tie up, °paung 綁, or vok 縳.
To put forth a proclamation, tsheh kau°-z° 出告示.

EXERCISES

(Translate into English)

(1) I-kuh zuh dzang-tsaung le theu meh-z°, tsauh dzak-ts meh


iau° °paung yi °chi-le.
(2) °Ngoo khoen°-kyien° sing-vung-°ts laung° wo° kwen-°foo
°i-kyung tsheh kau°-z° tsha ping-ting chi° tsauh °jang-
dau°.
(3) Noong° na°-nung °lau peh yi °tang, iung-we° °ngoo
°tang-’veh-koo° yi °lau.
(4) °Ngoo la° miau° °li khoen°-kyien° too-hau° ‘oo-zaung° la°
pa° boo-sah.
(5) Noong° iau° ‘auh kwen-wo° nyi ‘auh °Zaung-°he °thoo-bak.
(6) ‘Oo-zaung° tah-ts dau°-z° °z °liang yang° kuh, ‘oo-zaung°
m-meh deu-fah, dau° z° °yeu °bien-°ts kuh.
(7) °Ngoo dzang-°yoen ’veh khoen° sing-vung-°ts tse, kyung-
tsau °yeu sa° sing°-sih va°?
(8) Di°-kuh ih pau hoo°-suh sa°-ka° dien?
(9) I-kuh °siau-noen °kyi soe° tse? Lok soe°.
(10) Nyi-°s-ziang° °i-kyung °ma-ts ih te lok-tsen yui°-be° °zau
vaung-°ts.
(11) Ya°-°li °yeu nyoeh-liang°, nyung hwen-°hyi tsh dih.
(12) Di°-kuh ih pau °li-hyang° °yeu °kyi °kwen pih? °Yeu ih pak
°kwen.
(13) Yi we°-sa°-°lau ’veh °thau-nyang-°ts? Iung-we° yien°-°dze
°thau-’veh-°chi °lau.
(14) San laung° °Ngoo khoen° too-hau° hwo, °yeu ‘oong °lau
waung °lau bak, zeh-°dze °khau-°i wo° °ng-ngan-loh-suh
kuh.
(15) Nga°-kok nyung hwen-°hyi yoong° khan-pih °sia z°.
(16) Tau° °Zaung-°he ’veh °men nyan° °li-loo°, °lau ’veh °ba
zeh-nyi° °li-loo°.
(17) Iung-we° °ngoo khoen°-kyien° i-kuh °thau van°-kuh
dzang-°yoen ’veh chuh sa°, keh-°lau kyau° yoong°-
nyung peh °tien meh-z° yi chuh.
(18) Di° kuh pau iau° tsah °hau tan tau° tien° °li chi°.
(19) °Lau-zeh kau°-soo° °ngoo °z zeh-ke° ka°-dien ’va°?
(20) S° °lau tshih °lau pah °z sa° kuh soo°-mak? °Z zeh °kyieu.
(21) Nyi-koo °z, ’veh tsheh ka° kuh °siau-°tsia.

(一) 伊個賊常莊來偷物事捉着之末要綁伊起來.
(二) 我看見新聞紙上話官府已經出告示差兵丁去捉強盜.
(三) 儂那能佬撥伊打? 因爲我打勿過伊佬.
(四) 我拉廟裏看見多化和尙拉拜菩薩.
(五) 儂要學官話呢學上海土白.
(六) 和尚搭之道士是兩樣個和尙無沒頭髪道士有辮子個.
(七) 我常遠勿看新聞紙哉今朝有啥信息否?
(八) 第個一包貨色啥價錢?
(九) 伊個小囝幾歲哉? 六歲.
(十) 泥水匠已經買之一堆碌磚預備造房子.
(十一) 夜裏有月亮, 人歡喜吹笛.
(十二) 第個一包裏向有幾管筆? 有一百管.
(十三) 伊爲啥佬勿討娘子? 因爲現在討勿起佬.
(十四) 山上我看多化花有紅佬黃佬白實在可以話五顔六色個.
(十五) 外國人歡喜用鉛筆寫字.
(十六) 到上海勿滿念里路佬勿罷十二里路.
(十七) 因爲我看見伊個討飯個長遠勿吃啥蓋佬叫傭人撥點物事伊
吃.
(十八) 第個包要紥好拿到店裏去.
(十九) 老實告訴我是實蓋價錢否.
(二十) 四佬七佬八是啥個數目? 是十九.
(廿一) 尼姑是勿出嫁個小姐.

(Translate into Chinese)

(1) If you do not read the newspaper, you will not know the
news, and then when you converse with others, you will
have nothing to say.
(2) When a man dies the Chinese invite Buddhist and Taoist
priests to the house to perform funeral ceremonies.
(3) I put my pen and pencil on my writing table, but now I
cannot find them; has any one been in and taken them?
(4) Which do you think is the pleasanter to listen to, mandarin
or the Shanghai dialect?
(5) When I was young I very much liked to play the flute.
(6) A thief enters secretly and steals things, a robber kills men
and enters and takes things by force.
(7) Chinese are called yellow men, foreigners white men.
(8) When you go to the shop, ask the price of the boots, and
come and tell me.
(9) I caught the thief and bound him to the tree.
(10) If you use a foreign pen to write Chinese characters, they
do not look well; you must learn to use a Chinese pen.
(11) The Chinese beggars in the city are numberless.
(12) When the Mandarin has important things to announce to
the people, he puts forth a proclamation.
(13) I saw more than a thousand soldiers.
(14) The merchant bought more than five hundred chests of
tea.
(15) Are three hundred dollars sufficient to buy the house? Less
than three hundred will do.

(一) 苦然儂勿看新聞紙信息儂勿會曉得難沒儂搭別人白話儂無啥
好話.
(二) 人死之末中國人請和尙佬道士到屋裏來念經.
(三) 我個筆佬鉛筆擺拉寫字檯上但是現在尋勿着, 有啥人進來拿
脫否?
(四) 儂想官話佬上海土白那裏一樣好聽點?
(五) 年紀輕個時候我蠻歡喜吹笛.
(六) 賊末偷伴之進來偷物事強盜末打殺之人佬進來搶物事.
(七) 中國人是叫黄人外國人是叫白人.
(八) 儂到店裏去問鞋子個價錢來告訴我.
(九) 我捉之伊個賊佬綁伊拉樹上.
(十) 若然用外國筆佬寫中國字是勿好看個儂終要學用中國筆.
(十一) 城裏個告化子無數目拉.
(十二) 官府有要緊個事體對百姓話末伊要出告示.
(十三) 我看見勿罷一千兵丁.
(十四) 生意人買之勿罷五百箱個茶葉.
(十五) 買房子三百塊洋錢有末? 勿消三百塊個.

Notes.

(1) To marry a wife is expressed by °Thau nyang-°ts. When we speak of a


woman being married we use the expression Tsheh ka° (出嫁), literally
to go forth from the house or family. The woman leaves her own family
entirely and joins the family of the husband whom she marries.
(2) The words ’Veh-°ba (勿罷), more than, and ’Veh siau (勿消), less than,
are used in answer to questions. The words ’Veh-°men (勿滿) are often
used for less than, meaning literally “Not full.”
(3) In the second sentence of the Second Exercise “to perform funeral
ceremonies” should be translated Tsoo° koong-tuh (做功德), or Nyan°-
kyung (念經). It means to say masses for the soul of the departed.
(4) In the thirteenth sentence of the Second Exercise, “More than a thousand
soldiers” can be expressed Ih tshien too (一干多) and in the fourteenth
sentence “More than five hundred chests of tea” °Ng pak too (五百多).
(5) In the fifteenth sentence of the Second Exercise the answer would be
’Veh siau san pak kwhe° (勿消三百塊).
(6) In the fifth sentence of the Second Exercise “When I was young” is
translated Nyien kyi° chung° kuh z-‘eu° (年紀輕個時候), literally “The
time when my years were light”.
(7) In the eleventh sentence of the Second Exercise “Numberless” is
translated m-soo°-mak (無數目), literally “Without number.”

LESSON XXI
Verbal Idioms, Ordinals, and Remarks on the Expression of
Time

To express the idea of “about to do a thing” in Chinese you can


use the words tsiang-iau° ( 將 要 ). Tsiang-iau°-chi° ( 將 要 去 )
means “about to go.” Tsiang-iau° °si ( 將 要 死 ) means “about to
die.” Another way of expressing the same idea is by adding kwha°
tse after the verb. Kwha° means “fast.” Chi° kwha° tse (去快哉)
means “I will go fast,” that is, in a moment. Le kwha° tse (來快哉)
means “will come fast,” that is, in a few minutes. Thih-°tsung is
often used, meaning “just on the point of doing a thing.” Thus
°Ngoo thih-°tsung iau° chi° ( 我 貼 準 要 去 ) means “I was just
going.”
The expression “According to,” or “as it seems to me,” is expressed
in Chinese by the words tsau° °ngoo khoen° ( 照 我 看 ). Tsau°
°ngoo ( 照 我 ) used alone would mean “Follow me,” “Follow my
example.”
The Ordinals are formed from the Numerals in a very simple way.
The word deu (頭) is prefixed before the first numeral and di° (第)
before all the others. Thus “the first” is deu ih (頭一), the second is
di° nyi° (第二), the third is di° san (第三), and so on. When first is
used with the verb in the sense of the action being prior to some
other action the word sien (先) is used. Thus we have Noong° veh
zung tsheh chi° kuh zien-deu °ngoo sien iau° kau°-soo°
noong° ih tsaung z°-°thi (儂勿曾出去個前頭我先要告訴儂一莊事
體 ), meaning, “Before you go I first want to tell you something.”
Again Sien tsoo° di°-yang° nan-meh tsoo° i-yang° (先做第樣難
末做伊樣) means “First do this and then do that.” Again we have for
the same expression Sien tsoo° di° kuh, man° tsoo° i-kuh (先做
第個慢做 伊個), “First do this, slowly do that.”

REMARKS ON TIME

About midnight, pen°-ya°-°po 半夜把.


Just before daylight, thien-liang°-kwha° 天亮快.
In the evening, waung-hwung-deu 黃昏頭, or waung-
hwung-°doong 黃昏動.
Last month, zien-nyoeh 前月, or zien kuh nyoeh 前個月.
Next month, °‘au-nyoeh 下月, or °‘au kuh nyoeh 下個月.
First part of the month, nyoeh deu 月頭, or nyoeh-deu-
laung° 月頭上.
The end of the month, nyoeh °ti 月底.
The middle of the month, nyoeh-pen° 月半.
Every month, nyoeh-nyoeh 月月, nyoeh-too 月多, or °’me-
nyoeh 每月.
First day of the month, tshoo-ih 初一; second day of the
month, tshoo nyi° 初二, and so on up to the tenth day
of the month, which is tshoo zeh. After that di° 第 is
used instead of tshoo. Thus the thirteenth of the month
would be di° zeh-san 第十三.
A year, ih-nyien 一年.
Half a year, pen°-nyien 半年.
This year, kyung-nyien 今年.
Last year, jeu°-nyien 舊年.
Next year, khe-nyien 開年, le-nyien 來年, ming-nyien 明年.
Every year, nyien-nyien 年年, each year, °’me-nyien 每年. (See
note).
The new year, sing-nyien 新年.
New year’s day, nyien-tshoo-ih 年初一.
The end of the year, nyien ya° 年夜, literally “the night of the
year.” Also we have nyien-°ti 年底.
At the beginning of the year, nyien-deu-laung° 年頭上.
To pass from the old year to the new, koo° nyien 過年.
°Zaung-pen° and °‘au-pen° are used with year, month, and
night, just as they are used with day to denote the first
half and the second half. Thus we have °zaung-pen°-
nyien 上半年 for the first half of the year, and °‘au-
pen°-nyien 下半年 for the second half.
Rice (bought in the shop), °mi 米.
Work, sang-wei 生活.
Answer, we-sing° 回信.
Beginning, °chi-deu 起頭.
Again, tse° 再.

EXERCISES

(Translate into English)

(1) Leh-la° nyoeh-pen°, nyoeh-liang° °ting °hau khoen°.


(2) °Hoo-loo iau° °iung kwha° tse °soo-°i iau° ka-°thien me.
(3) Tsau° °ngoo khoen°, di° kuh nyung °z khau°-’veh-dzu° kuh.
(4) °Tsau-zung-deu nyih-deu tsheh le, ya°-kwha° lauh-san.
(5) Di°-kuh °z °ngoo di° nyi° kuh nyi-°ts, deu ih kuh °i-kyung
tsheh mung tse.
(6) Nyien tshoo ih too-hau° nyung chi° pa° nyien.
(7) Jeu° nyien °mi kyui°-le-°si, kyung nyien jang tse.
(8) Noong° °‘a-°li-deu koo° nyien? °Ngoo °siang la° ok-°li koo°
nyien.
(9) Noong° su dok°-ts °kyi-z tse? Pih-koo° pen° nyien.
(10) Nyien ya° nyung nyung °yeu z°-°thi, sing-nyien °li °loong-
°tsoong nyung beh-siang°.
(11) Yi tsiang-iau° chi° kuh z-‘eu° °yeu nyung le kyau° yi ’veh
iau° chi°.
(12) °Tshing zoo° ih hyih, sien-sang iau° le kwha° tse.
(13) Thien-liang°-kwha° °z °ting °lang kuh z-‘eu°.
(14) °‘Au kuh nyoeh °ngoo iau° tsheh mung, tau° Soo-tseu
chi°.
(15) Jeu°-nyien sang-i° ih ngan ’veh °hau kyung-nyien po-
maung° yi °hau-°tien.
(16) °Zaung-pen°-nyien di° kuh ‘auh-sang-°ts su dok le man
°hau, °‘au-pen°-nyien ih ngan ’veh °hau.
(17) I-zak vaung-°ts °kyi-z °khau-°i °zau °hau? °Ngoo °siang
khe-nyien °khau-°i °zau °hau.
(18) Lok nyoeh tshoo-san °ngoo °sia ih foong sing° peh la° yi,
yien°-°dze °z tshih nyoeh tshoo-ih dan°-°z wan ’veh zung
°yeu we-sing° le.
(19) Noong° ’veh zung tsheh chi°, sang-weh iau° sien tsoo°
°hau.
(20) Nyoeh-deu laung° peh doong-dien, yien°-°dze ’veh °hau
peh kuh.

(一) 垃拉月半月亮頂好看.
(二) 火爐要隱快哉所以要加添煤.
(三) 照我看第個人是靠勿住個.
(四) 早晨頭日頭出來夜快落山
(五) 第個是我第二個兒子頭一個已經出門哉.
(六) 年初一多化人去拜年.
(七) 舊年米貴來死今年強哉.
(八) 儂那裏頭過年? 我想拉屋裏過年.
(九) 儂書讀之幾時哉? 必過半年.
(十) 年夜人人有事體新年裏攏總人勃相.
(十一) 伊將要去個時候有人來叫伊勿要去.
(十二) 請坐一歇先生要來快哉.
(十三) 天亮快是頂冾個時候.
(十四) 下個月我要出門到蘇州去.
(十五) 舊年生意一顔勿好今年把望伊好點.
(十六) 上半年第個學生子書讀來蠻好下半年一顔勿好.
(十七) 伊宅房子幾時可以造好? 我想開年可以造好.
(十八) 六月初三我寫一封信撥拉伊現在是七月初一但是還勿曾有
回信來.
(十九) 儂勿曾出去生活要先做好.
(二十) 月頭上撥銅錢現在勿好撥個.

(Translate into Chinese)

(1) We will close the school on the fifth of next month.


(2) For how many weeks will you close the school? For about
six weeks.
(3) Sometimes in the evening as the sun is sinking there are
many beautiful colours in the sky.
(4) As it appears to me you can finish this book in six months.
(5) Just as I was about to go to sleep, I heard some one call
out that the house was on fire.
(6) The thief enters about midnight.
(7) Before you go to school you should first wash your face and
hands.
(8) On the first day of the year all the shops close their doors.
(9) When will you begin to study Chinese again? I think next
year.
(10) A year has twelve months, a month has thirty days or
twenty-nine days. If it has thirty days, it is called a large
month; if it has twenty-nine days, it is called a small
month.
(11) Last month I was sick, but now I am better.
(12) Where were you yesterday afternoon? I had gone out to
pay New Year’s calls.
(13) At New Year’s time every one wears their best clothes.
(14) Now I have no money; I will pay you at the end of the
month.

(一)下個月初五伲要放學.
(二)放之幾個禮拜? 約酌六個禮拜.
(三)拉夜快日頭落山個時候常時拉天上有多化趣個顔色.
(四)照我看第本書儂六個月功夫可以讀完.
(五)我貼準要困個時候聽見人喊房子火着哉.
(六)賊進來是半夜把個時候.
(七)儂勿曾到學堂裏先要揩面佬淨手.
(八)拉年初一攏總個店全關門個.
(九)儂幾時再起頭讀中國書? 我想開年起頭.
(十)一年有十二個月一個月或者有三十日或者有念九日, 若然三
十日是叫大月若然念九日是叫小月.
(十一) 前個月我生病哉但是現在我好點.
(十二) 昨日下半日儂拉那裏頭? 我出去拜年哉.
(十三) 垃拉新年裏各人着頂好看個衣裳.
(十四) 現在無沒銅錢垃拉月底撥儂.

Notes.

(1) In regard to the expressions Nyien-nyien and Nyoek-nyoeh it may be


remarked that a very common way of forming the plural in Chinese is
by the repetition of the noun. Thus Nyung-nyung means men in
general.
(2) In the sixth sentence of the First Exercise the expression Pa° nyien means
“to pay respects at New Year’s time.” Pa°, to worship, is used of
worshipping deities, and also of worshipping or paying respect to men.
(3) In the fifth sentence of the Second Exercise the expression for a house to
be on fire is °Hoo-dzak tze, (火着哉).
(4) In the eighth sentence of the Second Exercise “all the shops” is translated
°loong-°tsoong kuh tien° zen (攏總個店全); the zen (全) makes the
assertion more emphatic.

LESSON XXII
On Comparison

The usual way of forming the Comparative Degree of Adjectives


has already been stated.
When two things are compared with one another in Chinese the
words °pi (比) or °pi-ts (比之) are used between them. Thus °Mo
°pi-ts °keu doo° (馬此之狗大) means, “the horse is larger than the
dog.” Yi °pi noong° °hau (伊此儂好), “He is better than you.”
There are a good many other ways of expressing comparison.
Thus ’Veh jih (勿及) means, “not equal to.” Also we have ’Veh zu
(勿如), meaning, “not equal to, or not up to.”

VOCABULARY

To present or send, to escort a person on the way, soong° 送.


To count, °soo 數.
To reckon, soen° 算.
To send (a person), tsha 差.
To send a letter, kyi° 寄.
To deport oneself, to treat others, °de 待.
To treat rudely, °de man° 怠慢.
To keep, observe, °seu 守.
To knock the head on the ground, to kowtow, kheh-deu 磕頭.
A loaf, ih kuh men-deu 一個饅頭.
A stone mason, ih kuh zak-ziang° 一個石匠.
A hammer, ih kuh laung-deu 一個榔頭, or ih °po 一把.
A wine shop, ih ban °tsieu tien° 一爿酒店.

Te° (一對) is the classifier denoting a pair or a brace.

A pair of fowls, ih te° kyi 一對雞.


A pair of candles, ih te° lah-tsok 一對臘燭.
A husband and wife, ih te° foo-tshi 一對夫妻.

°Kheu (口) is the classifier for some articles of furniture, and for a
well.

A book case, ih °kheu su-dzu 一口書櫥.


Convenient, bien°-taung° 便當.
Clever, wise, tshoong-ming 聰明.
Propriety, custom, kwe-°kyui 規矩.
Coffin, ih °kheu kwen-ze 一口棺材.
Sometimes, dzang-z 常時.
As if, like, °hau-°ziang 好像.
To compare, °pi 比.
An account, tsang° 張.
Reason, yoen-koo° 緣故.

EXERCISES

(Translate into English)

(1) La° nyien ya° kauh nyung iau° soen° tsang°.


(2) Noong° we°-sa°-°lau iau° chi°? iung-we° yi tsha °ngoo chi°
°lau.
(3) Sing° kyi°-tsheh chi° meh? ’Veh zung, zieu° iau° kyi° chi°.
(4) Zak-ziang° iau° yoong° °kyi kwhe° zak-deu? °Ngoo ’veh
hyau°-tuh ’veh-zung soen° koo° hyih.
(5) Yi dzang-tsaung °de °ngoo ’man °hau, °soo-°i °ngoo iau°
soong° °tien meh-z° la° yi.
(6) Su-dzu °li noong° °pa-ts °kyi °pung su? ’Veh °hyau-tuh
we°-°ts ’veh zung °soo °lau.
(7) Khak nyung tsheh chi° meh iung-ke soong° yi tau° mung-
°kheu.
(8) Di°-°kheu kwen-ze sa° nyung tsoo° kuh? Mok-ziang° tsoo°
kuh.
(9) Noong° kuh °mo °pi °ngoo kuh kwha° too-hau°.
(10) Di°-kuh ‘auh-sang-°ts °pi-ts i-kuh tshoong-ming °tien.
(11) Di°-kuh ih te° lah-tsok °khau-°i °pi °pi khoen°, ih ngan m-
meh doo° °siau.
(12) I-kuh °liang kuh nyung siang-mo° kuh yoen-koo° °z we°-
°ts la° °tsieu tien° °li too-chuh-ts °tsieu °lau.
(13) Yien°-°dze foo° tsang° ’veh bien°-taung°, °tung tau° °‘au
kuh nyoeh.
(14) Di°-kuh ih te° foo-tshi ’man °hau ih ngan ’veh siang-mo°.
(15) Di°-kuh nyung tsoo° z°-°thi, ’veh jih i-kuh nyung °hau.
(16) Pa° nyien kuh z-‘eu° °siau-noen iung-ke te° doo° nyung
kheh-deu.
(17) °Nga-kok nyung chuh van° kuh zung-kwaung hwen-°hyi
chuh men-deu.
(18) Di°-kuh nyung ih ngan ’veh °toong sa°, °z °hau-°ziang
’veh zung dok hyih su.
(19) Sien-sang dzang-tsaung kyau° ‘auh-sang-ts° °seu kwe-
°kyui.
(20) ’Veh iau° °de man° bih nyung.

(一) 拉年夜各人要算帳.
(二) 儂爲啥佬要去? 因爲伊差我去佬.
(三) 信寄出去末? 勿曾, 就要寄去.
(四) 石匠要用幾塊石頭? 我勿曉得勿曾算過歇.
(五) 伊常莊待我蠻好所以我要送點物事拉伊.
(六) 書橱裏儂擺之幾本書? 我勿曉得爲之勿曾數佬.
(七) 客人出去末應該送伊到門口.
(八) 第口棺材啥人做個? 木匠做個.
(九) 儂個馬比我個快多化.
(十) 第個學生子比之伊個聰明點.
(十一) 第個一對臘燭可以比比看一顔無末大小.
(十二) 伊個兩個人相駡個緣故是爲之拉酒店裏多吃之酒佬.
(十三) 現在付帳勿便當等到下個月.
(十四) 第個一對夫妻蠻好一顔勿相駡.
(十五) 笫個人做事體勿及伊個人好.
(十六) 拜年個時候小囝應該對大人磕頭.
(十七) 外國人吃飯個晨光歡喜吃饅頭.
(十八) 第個人一顔勿懂啥好像勿曾讀歇書.
(十九) 先生常莊叫學生子守規矩.
(二十) 勿要待慢別人.

(Translate into Chinese)

(1) The Chinese use rice to make wine.


(2) This man treats his servants very well.
(3) According to Chinese custom before a man dies his coffin is
made.
(4) If I wish you to come, I will send you a letter.
(5) To take the child along with us will not be convenient.
(6) He is older than you.
(7) The stone mason uses stones, the carpenter uses wood.
(8) I pay my bills at the end of the month.
(9) He and I have had a quarrel because he treated me rudely.
(10) I wish the carpenter to come and make a book case.
(11) Because I have forgotten so many characters, it is as if I
had not read this book before.
(12) A scholar is wiser than a farmer.
(13) If a man takes too much wine he can not do his work.
(14) My friend came to visit me, and then I escorted him to his
home.
(15) This book I will present to you, do not return it.

(一) 中國人用米做酒.
(二) 第個人待伊個用人蠻好.
(三) 照中國規矩一個人勿曾死先要做棺材.
(四) 若然要儂來末我寄一封信來.
(五) 帶小囝去是勿便當.
(六) 伊比之儂年紀大點.
(七) 石匠用石頭木匠用木頭.
(八) 我個帳是拉月底付個.
(九) 因爲伊待慢我所以我對伊相駡.
(十) 我要木匠來做一口書橱.
(十一) 因爲我忘記脫之多化字所以好像我勿曾讀歇第本書.
(十二) 讀書人比之種田人聰明點.
(十三) 若然一個人多吃之酒伊勿會做生活.
(十四) 我個朋友來望望我後來我送伊到伊屋裏去.
(十五) 第本書我送撥儂勿要還個.

Notes.

(1) In the fifth sentence of the First Exercise notice the use of Soong° °tien.
°Tien means “a few things.”
(2) In the ninth sentence of the First Exercise kwha° too-hau° means “very
much faster.”
(3) In the sixteenth sentence of the First Exercise the expression Kheh-deu
refers to the most formal salute of the Chinese. It is used by an inferior
before a superior. The usual polite salutation is to clasp the hands
together and move them from the feet to the forehead. This is called
Tshaung° zo° (唱喏) or Tsauh-ih (作揖).
(4) In the nineteenth sentence of the First Exercise we have the expression
°Seu kwe-°kyui (守規矩). This is very frequently used. It means to act
according to the laws of propriety. It is a command frequently given to
children.

LESSON XXIII
The Points of the Compass
The four cardinal points of the compass in Chinese are expressed:
Toong, nen, si, pok (東, 南, 西, 北) East, South, West, North. Thus
it will be seen that they do not follow the same order as we. North
East is Toong-pok (東北), lit. East North. North West is Si-pok (西
北 ), lit. West North. South East is Toong-nen ( 東 南 ) , and South
West is Si-nen (西南).
The word pien (邊) is generally added when direction or place is
indicated. Thus we have for the North Pok-pien, for the West Si-
pien. Pien literally means “side,” and is a shortened form of pien-
deu (邊頭).
In giving directions as to locality, the Chinese make very frequent
use of the points of the compass.If you wish a person to go towards
the North you say dzau pok (朝北) “towards the North.”

VOCABULARY

To break, smash, se° 碎, °tang-se° 打碎, or khau-se° 敲碎.


To beget to nourish, °yang 養, or sang °yang 生養.
To lose, to forfeit, seh 失, or seh-theh 失脫.
To arrange, to attend to matters, to direct ban° 辦.
A Compradore, °ma-ban° 買辦.
To consult, saung-liang 商量, tsung-tsak 斟酌.
To point with the hand, °tien 點, or °ts-°tien 指點.
To separate, fung 分, or fung-khe 分開.
To hinder, oppose, °tsoo 阻, or °tsoo-taung° 阻檔.
To answer, we-deu 回頭, or we-tah 回答.
To exchange, to barter, wen° 換, or diau° 調.
To attend to a thing to make it right, loong° 弄, or loong°-
°hau 弄好.
To distinguish, fung-pih 分別.
A difference, ih kuh fung-pih 一個分別.
Wages, koong-dien 工錢.
Salary, sok-sieu 束脩, sing-foong° 薪俸, or sing-°soe 薪水.
Misery, °khoo-nau° 苦腦.
Rain, °yui 雨,
To rain, lauh °yui 落雨.
Coolie, tsheh-tien° 出店.
A duck, ih tsak ah 一隻鴨.
A broom, ih °po °sau-°tseu 一把掃箒.
A snake, ih diau zo 一條蛇.
A stick of bamboo, ih kung tsok-deu 一根竹頭.
Glass, poo-li 玻璃.
A glass (for the table), ih tsak poo-li pe-°ts 一隻玻璃杯子.

°Doong (桶) is the classifier for casks, tubs and buckets.

A bucket of water, ih °doong °s 一桶水.

Bing (瓶) is the classifier for bottles.

A bottle of medicine, ih bing yak 一瓶藥.

Siang (箱) is the classifier for boxes of things.

A box of dollars, ih siang yang-dien 一箱洋錢.


A box of tea, ih siang dzo-yih 一箱茶葉.
Tired, sa-doo 弛瘏.
Square, faung 方.
Round, yoen 圓.
Little (to a small extent), sau-we 稍爲.
Thick, °‘eu 厚.
Thin, bok 薄.
Instead of, °de-thi° 代替.
Sufficient, keu-z° 榖事, keu-z°-tse 彀事哉, or °yeu-tse 有哉.
Together with (two persons doing a thing), da-ka 大家.
To get wet, ling-sak 淋濕.
EXERCISES

(Translate into English)

(1) Tsoong-kok tsok-deu doo° °yeu yoong°-deu, °khau-°i tsoo°


lan °lau de-°ts °lau iui°-°ts °lau too-hau° meh-z°.
(2) °Ngoo mung°-°ts yi san we, dan°-°z yi ih kyui° ’veh we-
deu.
(3) Tsoong°-dien-nyung °yang too-hau° kyi °lau ah.
(4) °Hau-la-va°? °Hau-la zia°-zia°.
(5) Kyung-tsau °hau-°tien va°? Zauh-ya°-deu chuh-ts yak °lau
kyung-tsau sau-we °hau-°tien.
(6) Nyih-deu toong-pien tsheh °lau si-pien lauh.
(7) Pok-pien °lang °lau nen-pien °noen.
(8) °Ngoo-nyi iau° da-ka saung-liang na°-nung tsoo°-deu.
(9) Di°-kuh poo-li ’man bok kuh, yoong-yi° °tang-se°.
(10) Khoen°-kyien° nyung iau° tsoo° ’veh °hau kuh z°-°thi
meh, iung-ke °tsoo-taung° yi.
(11) Khoen°-yang-nyung seh-theh-ts ih tsak yang °lau iau° chi°
zing yi.
(12) Sien-sang iau° °kyi-hau° sok-sieu? Iau° san-seh kwhe°
°yang-dien ih nyoeh.
(13) Noong°-kuh yoong°-nyung °kyi-hau° koong-dien ih nyoeh?
Zeh kwhe° yang-dien ih nyoeh.
(14) Toong-pok foong iau° lauh °yui.
(15) Yien°-°dze la° lauh °yui, tsoong-iau° tan ih °ting san°
°sang-°ts ling sak.
(16) Zauh-nyih °ngoo °tseu-°ts san-seh °li-loo°, °soo-°i kyung-
tsau ’man sa-doo.
(17) °Ngoo °tien peh yi khoen° ih diau zo.
(18) Di°-kuh kwen-°foo ’veh we° ban° z°-°thi.
(19) Noong° °tau le-tse, °ngoo thih-tsung iau° tau° noong°
han-deu chi°.
(20) Di°-kuh nyung seh-theh-°ts yi-kuh sang-i °lau sang-°ts
dzang-yoen kuh bing° zeh-dze °khoo-nau° tuh-juh.
(21) Di°-tsak siang-°ts °z faung kuh, di°-tsak °doong °z yoen-
kuh.
(22) Tsheh-tien° le wo° iau° doong-dien we°-ts iau° chi° °ma ih
°po °sau-°tseu °lau.
(23) Di°-kuh °ts-deu thuh bok iau° noong° chi° wen° °‘eu-°tien
kuh.
(24) Noong° thuh sa-doo, °ngoo le °de noong° tsoo°.
(25) Di°-sen° °mung ’veh °hau khe, chi° kyau° mok-ziang loong
°hau.
(26) Yi-kuh seh-wo° tah-ts noong°-kuh seh-wo° °yeu fung-pih.
(27) Di°-kuh °liang kuh nyung dzang-tsaung siang-mo°, fung-
khe meh °hau.

(一) 中國竹頭大有用頭可以做籃佬檯子佬椅子佬多化物事.
(二) 我問之伊三回但是伊一句勿回頭.
(三) 種田人養多化雞佬鴨.
(四) 好拉否? 好拉謝謝.
(五) 今朝好點否? 昨夜頭吃之藥佬今朝稍爲好點.
(六) 日頭東邊出佬西邊落.
(七) 北邊冷佬南邊煖.
(八) 我伲要大家商量那能做頭.
(九) 第個玻璃蠻薄個容易打碎.
(十) 看見人要做勿好個事體末應該阻擋伊.
(十一) 看羊人失脫之一隻羊佬要去尋伊.
(十二) 先生要幾化束脩? 要三十塊洋錢一月.
(十三) 儂個用人幾化工錢一月? 六塊洋錢一月.
(十四) 東北風要落雨.
(十五) 現在拉落雨終要擔一頂傘省之淋濕.
(十六) 昨日我走之三十里路所以今朝我蠻弛瘏.
(十七) 我點擦伊看一條蛇.
(十八) 第個官府勿會辦事體.
(十九) 儂倒來哉我貼準要到儂壗頭去.
(二十) 第個人失脫之伊個生意佬生之長遠個病實在苦惱得極.
(廿一) 第隻箱子是方個第隻桶是圓個.
(廿二) 出店來話要銅錢爲之要去買一把掃帚佬.
(廿三) 第個紙頭忒薄要儂去換厚點個.
(廿四) 儂忒弛瘏我來代儂做.
(廿五) 第扇門勿好開去叫木匠弄好.
(廿六) 伊個說話搭之儂個說話有分別.
(廿七) 第個兩個人常莊相駡分開末好.

(Translate into Chinese)

(1) Is there any answer? Yes, please wait until I write it.
(2) The cold wind blows from the North; you ought to wear
more clothes.
(3) The scholar was unable to answer what the teacher asked
him.
(4) I want to consult with you on an important matter.
(5) When it rains the children cannot go out to play.
(6) I have a fan, you have a knife, I want a knife, you want a
fan, let us exchange.
(7) I killed the snake with a stick.
(8) Tell the compradore what you want to buy and he can buy it
for you.
(9) I have lost my watch and am willing to give five dollars to
the man who finds it and returns it to me.
(10) My salary is not sufficient; I must ask you to increase it.
(11) This coolie wipes and sweeps very clean.
(12) I pointed out the river to him on the map.
(13) I cannot go away until I have arranged this matter.
(14) I could not study diligently to-day because I was too tired.
(15) How many bottles of medicine have you taken? I have
already finished three.

(一) 有啥回信否? 有個, 請等一歇等我寫好之.


(二) 冷風從北邊吹來儂應該多着點衣裳.
(三) 先生問個, 學生子回頭勿出.
(四) 我要搭儂商量要緊個事體.
(五) 落之雨小囝勿好出去勃相.
(六) 我有一把扇子儂有一把刀我要一把刀儂要一把扇子讓我伲調
一調.
(七) 我用之一根棒打殺之一條蛇.
(八) 儂對買辦話儂要買啥伊可以對儂買個.
(九) 我失脫之我個表情願撥拾着之佬還撥我個人五塊洋錢.
(十) 我個薪水勿彀事我終要請儂加點.
(十一) 第個出店揩佬掃蠻割瀝.
(十二) 地圖上我點撥伊看一條河.
(十三) 我勿曾辦好第莊事體我勿能彀出去.
(十四) 今朝我勿能彀用心讀書因爲我忒弛瘏.
(十五) 儂吃之幾瓶藥? 我已經吃完之三瓶.

Notes.

(1) Those learning to speak Chinese must be careful never to refer to the
remuneration given to their teachers as koong-dien (工錢), but to use
the polite form of speech, sok-sieu or sing-foong (束脩, 薪俸). Sok-sieu
means literally “dried meat,” and comes from the ancient custom of
paying a teacher in kind. The teacher himself could refer to
remuneration as sing° soe (薪水).
(2) °Eu (厚) and Bok (薄) refer to things. In speaking of a person being thin
we use the word seu° (瘦), and of being fat, the word tsaung° 壯.
(3) The fourth sentence of the First Exercise is the usual salutation meaning,
“How do you do?” “Does it go well with you?” The answer is also the
usual one.
(4) In the ninth sentence of the Second Exercise Zing nyoen° (情願) means
“to be willing.”
(5) In the seventh sentence of the First Exercise °Noen means “warm” (煖).
(6) In the eleventh sentence of the First Exercise Koen°-yang-nyung means
“shepherd.” Literally “Look-sheep-man.”
(7) In the twenty-fifth sentence of the First Exercise the word Loong has a
very wide meaning. There is hardly anything in China that you cannot
Loong-°hau, that is, “put to rights.”
LESSON XXIV
Some Remarks on Gender

As already remarked, words in Chinese do not change their form


to indicate gender. Sometimes, however, words indicating gender are
placed before them. Nen (男), “Male” and °Nyui (女), “female”, are
used with human beings in this way. Thus we have Nen nyung (男
人 ) for “man”, and °Nyui nyung ( 女 人 ) for “woman”. Nen noen
( 男 囝 ) means “a male child,” and °Nyui noen ( 女 囝 ) “a female
child.”
When speaking of the male and female of animals Yoong ( 雄 )
and Tsh (雌) are used. Thus we have Yoong kyi (雄鷄) for “cock,”
and Tsh kyi (雌鷄) for “hen,” Yoong s-°ts (雄獅子) for “lion,” and
Tsh s-°ts (雌獅子) for “lioness.”

VOCABULARY

To crow, di 啼.
To offend, tuh-°dzoe 得罪.
To hide oneself, ben°-°loong 背攏.
To hide a thing, khaung°-°loong 囥攏, or khaung° 囥.
To gain or make a profit, dzan° 賺.
Profits in business, dzan°-deu 賺頭.
To lose in business, zeh 折, zeh-theh 折脫, zeh-°pung 折本.
To congratulate a person, koong-°hyi 恭喜.
To become rich, fah-dze 發財.
To lock, °soo 鎖.
To bar or bolt the door, sen 閂.
The bar, or bolt of the door, sak 栅.
To plant, tsoong° 種.
To examine carefully, dzo 查, or dzo-°khau 查考.
To examine a class, °khau-su 考書.
To fall, tih 跌.
To save, kyeu° 救.
To stop, ding 停.
Stop a minute, ding-ih-ding 停一停.
Garden, hwo-yoen 花園.
College, su-yoen° 書院.
University, da°-‘auh 大學.
A lock, ih °po °soo 一把鑕.
A key, ih °po yak-dz 一把鑰匙.
A creek or canal, ih diau pang 一條浜.
A two story house, ih zoo° leu 一座樓, or leu-vaung 褸房.

Dzung (層) is the classifier for a story of a house or for anything


like a ladder.

A three-storied house, san dzung leu 三層樓.


A ladder, ih dzung voo-thi 一層扶梯.

Dzaung° (幢) is the classifier denoting things piled one on top of


the other.

A pile of clothes, ih dzaung° i-zaung 一幢衣裳.

Da° (埭) is the classifier for rows of things.

A row of trees, ih da° zu 一埭樹.


Spring (the first of the seasons), tshung 春.
Summer, ‘au° 夏.
Autumn, tshieu 秋.
Winter, toong 冬.
A season, kyi° 季.
The four seasons, s°-kyi° 四季.
Politeness, khak-chi° 客氣.
Happiness, fok-chi° 福氣.
Slippery, wah 滑.
Hard, ngang° 硬.
Soft, °nyoen 軟.
Smooth, kwaung 光.
Rough, mau 毛.
Good (moral), °zen 善.
Wicked, auh 惡.
Fierce, hyoong 凶.
Precious, °pau-pe° 寶貝.
Clear, tshing 清.
Muddy, wung 渾.
Level, bing 平.
Light (opposite of dark), liang° 亮.
Dark, en° 暗.
At last (in the end), tau°-°ti 到底.

EXERCISES

(Translate into English)

(1) Di°-laung° wah lau, taung-sing °tien °tseu.


(2) S°-kyi° kyau° tshung ‘au° tshieu toong.
(3) °Ngoo bang°-dzak-ts ih kuh nyung °lau iau° yi nyang° loo°,
°soo-°i te° yi wo° tuh-°dzoe, tuh °dzoe. Yi wo° ’veh iau°
khak-chi°.
(4) Noong° tsoo° °di-kuh sang-i, ih nyien iau° dzan° °kyi-hau°?
m-sa° dzan°-deu °tau zeh-°pung.
(5) Nyien tshoo ih, bang°-dzak-ts nyung tsau° kwe-°kyui iung-
ke te° yi wo° koong-°hyi, fah-dze.
(6) Nyung tsoo° auh kuh z°-°thi, °z la° en°-°li tsoo° kuh.
(7) We°-ts pho° bih nyung iau° dzo-dzak °lau, i-kuh nyung chi°
ben°-°loong.
(8) Ya°-°li tsoong-iau° °soo mung°, °khoong-pho° zuh tsing° le
theu meh-z°.
(9) Tsoong-kok mung° yoong° sak le sen kuh, nga°-kok mung°
yoong° yak-dz le °soo kuh.
(10) °Siau-noen la° beh-siang° kuh z-‘eu° tih la° pang °li,
kwha°-°tien chi° kyeu° yi.
(11) Yoong tiau we° kyau°, tsh tiau ’veh we° kyau°.
(12) Tsh s-°ts °pi-ts yoong s-°ts kung°-ka hyoong.
(13) Di°-kuh nyung °yeu san kuh nen-noen, °lau ih kuh °nyui-
noen, zeh-dze °yeu fok-chi°.
(14) Di°-kuh meh-z° °z °pau-pe° kuh, iau° khaung° °hau.
(15) °‘Au-°li-pa°, su-yoen° °li iau° °khau-su.
(16) Di°-kuh ih da° vaung-°ts kau-le-°si, °loong-°tsoong °z s°
dzung leu.
(17) Di°-diau loo° ’veh bing, van-nan °tseu kuh.
(18) Tshing °s °hau chuh kuh, wung °s ’veh °hau chuh.
(19) Zak-deu °z ngang° kuh, men-deu °z °nyoen kuh.
(20) Tau°-°ti meh °zen nyung ih ding° iau° tuh-dzak fok-chi°.

(一) 地上滑佬當心點走.
(二) 四季叫春夏秋冬.
(三) 我碰着之一個人佬要伊讓路, 所以對伊話得罪得罪, 伊話勿要
客氣.
(四) 儂做第個生意一年要賺幾化? 無啥賺頭倒折本.
(五) 年初一碰着之人照規矩應該對伊話恭喜發財.
(六) 人做惡個事體是拉暗裏做個.
(七) 爲之怕別人要查着佬, 伊個人去背攏.
(八) 夜裏終要鎖門, 恐怕賊進來偷物事.
(九) 中國門用栅來閂個, 外國門用鑰匙來鎖個.
(十) 小囝拉勃相個時候跌拉浜裏, 快點去救伊.
(十一) 雄窵會叫, 雌窵勿會叫.
(十二) 雌獅子比之雄獅子更加凶.
(十三) 第個人有三個男囝佬一個女囝, 實在有福氣.
(十四) 第個物事是寶貝個, 要囥好.
(十五) 下禮拜, 書院裏要考書.
(十六) 第個一埭房子高來死, 攏總是四層樓.
(十七) 第條路勿平, 煩難走個.
(十八) 淸水好吃個, 渾水勿好吃.
(十九) 石頭是硬個, 饅頭是軟個.
(二十) 到底末善人一定要得着福氣.

(Translate into Chinese)

(1) In the garden the gardeners have planted three rows of


apple trees.
(2) After the cock crows in the morning I am unable to sleep
any more.
(3) This man is very polite, and so every one likes him.
(4) In the winter we close all the doors and windows and light a
fire, in the summer we open all the doors and windows.
(5) The water in the creek is muddy and not fit to drink.
(6) Some men become rich in business, and some lose money.
(7) Lock the door and do not let the cat come in.
(8) The child fell off the chair and therefore cries.
(9) Yesterday I went to see a seven storied pagoda.
(10) This account is not right; it is not reckoned clearly.
(11) I cannot find out that this man has done anything wicked.
(12) When I met the robber I cried out to others to come and
save my life.
(13) This man is very fierce; he is always fighting.
(14) At the end of the year, all the scholars in the college must
be examined.
(15) I have lost my key and cannot open my box.
(16) I think you have not lost it, but you have hidden it away
somewhere, and have forgotten where you put it; let me
go and look for it.

(一) 拉花園裏種花園個種三埭蘋菓樹.
(二) 早晨頭雞啼個以後我勿能再睏.
(三) 第個人是蠻客氣所以攏總人歡喜伊.
(四) 冬天個時候我伲關攏總個門佬窗佬生火夏天個時候我伲開攏
總個門佬窗.
(五) 浜裏水是渾佬勿好吃個.
(六) 有人做生意是發財有人末折本.
(七) 鎖門佬勿要讓貓進來.
(八) 小囝從椅子上跌下來所以拉哭.
(九) 昨日我去看七層樓個塔.
(十) 第個帳勿對個算來勿淸爽.
(十一) 我查勿出第個人做啥惡事.
(十二) 我碰着之強盜我喊人來救命.
(十三) 第個人凶來死所以常莊相打.
(十四) 拉年底書院裏攏總個學生子要考書.
(十五) 我失脫之我個鑰匙佬勿好開我個箱子.
(十六) 我想儂勿曾失脫恐怕儂已經囥好佬忘記擺拉啥地方, 讓我
去尋尋看.
Notes.

(1) Tuh-°dzoe, tuh-°dzoe (得罪) is the usual expression for making an


apology in Chinese, It literally meant, “I have sinned against you.”
(2) A two storied house is generally called leu vaung (樓房).
(3) In the fifth sentence of the First Exercise we have the formal salutation
used on New Year’s Day Koong-°hyi, fah-dze (恭喜發財) meaning,
“may you be happy and grow rich.”
(4) In the twelfth sentence of the Second Exercise the expression to save life
should be Kyeu° ming° (救命).
(5) In the tenth sentence of the Second Exercise “this account is not
reckoned right” should be translated di°-kuh tsang° ’veh te° kuh (第個
帳勿對個); te° means “not in agreement.”

LESSON XXV
Weights and Measures

The following three Tables are very commonly used in China, and
the speaker of the language should be familiar with them.

MEASURE OF WEIGHT

One ounce, ih °liang 一兩.


One catty (16 ounces), ih kyung 一斤.
One picul (100 catties), ih tan° 一担.

MEASURE OF DISTANCE

1⁄10th of an inch, ih fung 一分.


One inch, ih tshung° 一寸.
One foot (ten inches in Chinese measure), ih tshak 一尺.
Tea feet, ih °dzang 一丈.
MEASURE OF AREA

One square foot, ih faung tshak 一方尺.


One hundred square feet, ih faung 一方.
A mow, ih °m 一畝 (one sixth of an acre).

CURRENCY

Until recently, aside from copper cash, the Chinese had no regular
system of currency. An ounce of silver was taken as a standard. The
following Table is based upon that:—

An ounce of silver, ih °liang nyung-°ts 一兩銀子.


(1⁄10th of an ounce, ih dzien 一錢.
(1⁄10th of a dzien, ih fung 一分.
(1⁄10th of a fung, ih li 一釐.
(1⁄10th of a li, ih ‘au 一毫.

VOCABULARY

To expound, explain, °kaung 講.


To preach, °kaung-su 講書.
To exhort, choen° 勸, choen°-mien 勸勉, choen°-‘oo 勸和.
To gather, as fruit or flowers, °tshe 採.
To boil zah 煠, (used in regard to water), or °kwung 滾.
To weigh, tshung 稱.
To measure, liang 量, or °ien 演.
To carry in arms like a child, °bau 抱.
To carry a load (one man, with load suspended on two ends of a
bamboo), thiau 挑.
To carry a load (load suspended on a bamboo pole between two
men), kaung 扛.
To carry a load on the back, pe° 背.
To carry a load on the shoulder, jien 掮.
To carry a load in one hand, ling 拎.

You might also like