100% found this document useful (2 votes)
37 views

Web Application Design and Implementation Apache 2 PHP5 MySQL JavaScript and Linux UNIX Quantitative Software Engineering Series 1st Edition Steven A. Gabarró 2024 Scribd Download

Series

Uploaded by

damilcater3s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
37 views

Web Application Design and Implementation Apache 2 PHP5 MySQL JavaScript and Linux UNIX Quantitative Software Engineering Series 1st Edition Steven A. Gabarró 2024 Scribd Download

Series

Uploaded by

damilcater3s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

Visit https://ebookgate.

com to download the full version and


explore more ebooks

Web Application Design and Implementation Apache 2


PHP5 MySQL JavaScript and Linux UNIX Quantitative
Software Engineering Series 1st Edition Steven A.
Gabarró
_____ Click the link below to download _____
https://ebookgate.com/product/web-application-design-
and-implementation-apache-2-php5-mysql-javascript-and-
linux-unix-quantitative-software-engineering-
series-1st-edition-steven-a-gabarro/

Explore and download more ebooks at ebookgate.com


Here are some recommended products that might interest you.
You can download now and explore!

Professional LAMP Linux Apache MySQL and PHP Web


Development 1st Edition Jason Gerner

https://ebookgate.com/product/professional-lamp-linux-apache-mysql-
and-php-web-development-1st-edition-jason-gerner/

ebookgate.com

PHP5 and MySQL bible Tim Converse

https://ebookgate.com/product/php5-and-mysql-bible-tim-converse/

ebookgate.com

Apache MyFaces 1 2 Web Application Development 1st New


edition Edition Bart Kummel

https://ebookgate.com/product/apache-myfaces-1-2-web-application-
development-1st-new-edition-edition-bart-kummel/

ebookgate.com

The Apache Modules Book Application Development with


Apache Prentice Hall Open Source Software Development
Series 1st Edition Nick Kew
https://ebookgate.com/product/the-apache-modules-book-application-
development-with-apache-prentice-hall-open-source-software-
development-series-1st-edition-nick-kew/
ebookgate.com
Setting Up LAMP Getting Linux Apache MySQL and PHP Working
Together 1st Edition Eric Filson

https://ebookgate.com/product/setting-up-lamp-getting-linux-apache-
mysql-and-php-working-together-1st-edition-eric-filson/

ebookgate.com

Handbook of Research on Mobile Software Engineering Design


Implementation and Emergent Applications 1st Edition Paulo
Alencar
https://ebookgate.com/product/handbook-of-research-on-mobile-software-
engineering-design-implementation-and-emergent-applications-1st-
edition-paulo-alencar/
ebookgate.com

JavaScript Application Design A Build First Approach 1st


Edition Nicolas Bevacqua

https://ebookgate.com/product/javascript-application-design-a-build-
first-approach-1st-edition-nicolas-bevacqua/

ebookgate.com

Software Specification and Design An Engineering Approach


1st Edition Ph.D.

https://ebookgate.com/product/software-specification-and-design-an-
engineering-approach-1st-edition-ph-d/

ebookgate.com

JavaScript The Web Warrior Series 6th Edition Sasha Vodnik

https://ebookgate.com/product/javascript-the-web-warrior-series-6th-
edition-sasha-vodnik/

ebookgate.com
Web Application Design
and Implementation
•• e T ..

~I t 807 ~
=1~WlLEY:
:12007 ;
-;
• '
. l e . . . T ..... I ...
.
r

THE WILEY BICENTENNIAL-KNOWLEDGE FOR GENERATIONS

<S achgeneration has its unique needsand aspirations. When Charles Wiley first
opened his small printing shop in lower Manhattan in 1807, it was a generation
of boundless potential searching for an identity. And we were there, helping to
define a new American literary tradition. Over half a century later, in the midst
of the Second Industrial Revolution, it was a generationfocusedon building the
future. Once again, we werethere,supplyingthe criticalscientific,technical,and
engineering knowledge that helped frame the' world. Throughout the 20th
Century, and into the :new millennium, nations began to reach out beyond their
own borders and a new international community was born. Wiley was there,
expanding its operationsaround the world to enable a global exchangeof ideas,
opinions, and know-how.

For 200 years, Wiley has been an integral part of each generation's journey,
enablingthe flowof information and understanding necessaryto meet their needs
and fulfill their aspirations. Today, bold new technologies are changing the way
we live and learn. Wiley will be there, providing you the must-have knowledge
you need to imaginenew worlds, new possibilities, and new opportunities.

Generations come and go, but you can always count on Wiley to provide you the
knowledge you need,when and whereyou need it!

Lu~';'~~.~ ~~u~
WILLIAM .... PESCE PETER BaaTH WILEY
PRESIDENT AND CHIEF' EXECUTIVE DFFlCER CHAIRMAN OF" THE BOARD
Web Application Design
and Implementation
Apache 2, PHP5, MySQL,
JavaScript, and Linux/UNIX

Steven A. Gabarro
Stevens Institute of Technology
Hoboken, New Jersey

IEEE
~computer
SOciety
60TH anniversary

"'
BICENTENNIAL

it807~
.
=~WILEY=z
.-
z
:2007~
,.~
BICENTENNIAL

WILEY-INTERSCIENCE
A John Wiley & Sons, Inc., Publication
Copyright © 2007 by John Wiley & Sons, Inc. All rights reserved.

Published by John Wiley & Sons, Inc., Hoboken, New Jersey.


Published simultaneously in Canada.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in


any form or by any means, electronic, mechanical, photocopying, recording, scanning, or
otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright
Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222
Rosewood Drive, Danvers, M,A 01923, (978) 750-8400, fax (978) 750-4470, or on the web at
www.copyright.com. Requests to the Publisher for permission should be addressed to the
Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030,
(201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permission.

Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their
best efforts in preparing this book, they make no representations or warranties with respect
to the accuracy or completeness of the contents of this book and specifically disclaim any
implied warranties of merchantability or fitness for a particular purpose. No warranty may be
created or extended by sales representatives or written sales materials. The advice and
strategies contained herein may not be suitable for your situation. You should consult with a
professional where appropriate. Neither the publisher nor author shall be liable for any loss
of profit or any other commercial damages, including but not limited to special, incidental,
consequential, or other damages.

For general information on our other products and services or for technical support, please
contact our Customer Care Department within the United States at (800) 762-2974, outside
the United States at (317) 572·-3993 or fax (317) 572-4002.

Wiley also publishes its books in a variety of electronic formats. Some content that appears
in print may not be available in electronic formats. For more information about Wiley
products, visit our web site at www.wiley.com.

Library of Congress Cataloging-in-Publication Data:


Gabarr6, Steven A., 1979-
Web application design and implementation: Apache 2, PHP5, MySQL,
JavaScript, and Linux/Unix / by Steven A. Gabarro,
p. em.
Includes index.
ISBN-13: 978-0-471-77391-7 (cloth)
ISBN-I0: 0-471-77391-3 (cloth)
1. Web site development. 2. Web sites-Design. 3. Application
software-Development. I. Title.
TK5105.8883.G33 2007
006.7-dc22
2006014999
Contents

Preface xiii
About the Author / xiii
Before We Get Started I xiii
Who Should Read This Book? I xiv
About the Examples I xiv
How to Read This Book I xiv

Acknowledgments xv

Introduction: Web Application Recipe 1


Overview I I
Procedure I I
Step I-Understanding the Problem and Finding the
Solution / 1
Step 2-Designing the Database / 2
Step 3-Major Functionalities / 2
Step 4-Backside / 2
Step 5-Irnprovements on Functionality I 2
Step 6-Irnprovements on Looks / 3
Step 7-Thorough Testing, Hacking Attempts / 3
Step 8-Presentation / 3
Step 9-Publication / 3
Step IO-Celebration (and Maintenance) I 4
v
vi CONTENTS

1. Fundamentals 5
The Origins of the Internet I 5
The World Wide Web I 6
The Web Browsers I 7
The Web Servers I 7
TCP/IP BASICS I 8
The Internet Layer I 9
The Transport Layer I 11
The Application Layer I 11
The Toolbox I 12
Browsers I 12
FTP I 13
Email Clients I 14
Programming Tools I 14
Other Useful Tools I 15

2. The Different Approaches of Web Programming 17


Before We Get Started I 17
The Basics-HTMloJ I 17
The Creator-SGML I 18
Other SGML-Based Languages-XML and XSL I 19
The Good Old Java / 20
Something Different-JavaScript / 21
The Savior-PHP I 22
The Rival-ASP.N]~T I 22
The Myth-CGI I 23
Another Big Option-Perl / 23
The Future?-C# / 24
Client-Side versus Server-Side-Which Side to Pick? I 24
My Choices-PHP, MySQL, JavaScript I 25

3. Introduction to HTML 27
What Do You Need to Get Started? I 27
How Does HTML Work? I 28
Syntax Basics / 28
File Structure I 28
Tag Parameters I 30
Basic Text Formatting I 30
External References I 32
Links I 32
Images I 33
CONTENTS vii

Organizing Data / 34
Lists / 35
Tables / 36
Frames / 39
Special Characters I 43

4. Work Environment 45
Introduction I 45
Downloading the Software I 45
Installing the Apache Server I 46
Installation Steps I 46
Checking the Installation I 47
Possible Errors I 47
Configuring Apache I 48
Installing PHP5 I 48
Testing PHP I 50
Installing MySQL I 50
Adding a MySQL User I 51
How Do I Know if MySQL is Running? I 51
Installing PhpMyAdmin I 51
Installing a Bulletin Board: phpBB I 52
Installation Steps I 52
Basic Security Considerations I 54
Conclusion I 55

5. PHP-A Server-Side Scripting Language 57


How Does It Work? I 57
Some "New" Words on PHP / 57
Syntax Generalities I 58
Instructions I 58
Operators I 61
Mathematical Functions I 61
Data Types I 63
Constants I 64
Variables I 65

6. PUP Arrays and Flow of Control 69


Arrays I 69
Basic Arrays / 69
Associative Arrays I 70
viii CONTENTS

Multidimensional Arrays / 71
Array Functions / 74
PHP Program Structure and Flow of Control / 77
Conditions / 77
Loops / 80
Functions / 82

7. Using Files, Folders, and Strings in PUP 85


Using Files / 85
Folder Manipulation / 89
Basic String Manipulation / 90
Changing a String / 90
Finding and Comparing / 93
Formatting Strings / 94
Manipulating HT~f1L Files / 95
PHP Information Functions / 96
Closing Remarks / 97
Writing a Basic File Explorer / 97
Requirements / 97
Hints / 98
Case Study: An Indexer/Searcher-Step 1 / 98
Overview / 98
The Indexer-Step 1 / 99

8. PUPS and Object-Oriented Programming 101


Overview / 101
Classes and Objects / 101
Classes in PHP / 102
Constructors and Destructors / 103
Visibility / 104
The Scope Resolution Operator / 105
The Static Keyword / 105
Class Constants / 106
Class Abstraction / 106
Object Interfaces / 106
Copying and Cloning Objects / 107
Comparing Objects / 108
Type Hinting / 109
Exceptions / 109
Final Words / 110
CONTENTS ix

9. Creating Some Interactivity 111


Overview / 111
Forms / 111
Writing a Form in HTML / 111
GET versus POST / 115
Retrieving the Form Infomation on a PHP Script / 115
Dynamically Creating Forms / 116
Transferring Data Between PHP Scripts / 117
Cookies / 117
Sessions / 120
One Last Useful Function and Design Techniques I 122
Assignments I 123
File Explorer-Step 2 / 123
Case Study: Indexer/Searcher-Step 2 / 124
10. Making Cleaner Code and Output 127
Cleaning Up Your Code / 127
What You Need / 127
How to Use It?-HTML Side I 128
How to Use It?-PHP Side / 128
Cleaning Up Your Output / 131
The CSS File I 132
Useful Tools / 134
Assignment / 135
11. Using Databases 137
Overview I 137
Database Basics I 137
The Entity Relationship Model / 137
More Practical Examples I 138
Typical Sources of Error / 139
Simplifying the Diagrams I 140
Using MySQL I 140
MySQL Syntax / 141
Data Types / 142
MySQL Numeric Data 1)rpes / 142
Date and Time Data Types / 143
String Data Types / 144
MySQL Operators / 144
MySQL Instructions / 145
Using Functions in MySQL / 150
X CONTENTS

12. Using PhpMyAdmin 151


Overview / 151
Creating a Database / 151
Creating Tables / 152
Accessing an Existing Table / 154
Exporting/Importing a Database Structure and Content / 154
Assignment-Final Project / 157

13. Creating Database-Driven Websites with PHP/MySQL 159


Overview / 159
Connecting to Your MySQL Server with PHP / 159
Submitting SQL Queries / 160
Processing the Results of a Query / 161
Example of Login Procedure / 162
Other Useful Functions / 163
Grouping Our Methods in a Class / 164
Indexer/Searcher-Steps 3 and 4 / 168

14. JavaScript-A Client-Side Scripting Language 171


Introduction / 171
JavaScript Syntax / 173
Types of Data and Variables I 173
Operations and Calculations / 173
Arrays / 175
Decisions / 176
Loops / 176
Using Functions / 177
Using Objects / 178
The String Objects / 178
The Math Class / 179
The Array Objects / 181
The Date Objects / 181

15. Programming the Browser 185


Overview / 185
The Window Object / 185
The Location Object / 186
The History Object / 186
The Navigator Object / 186
The Screen Object / 187
The Document Object / 187
CONTENTS xi

Using Events / 191


Timers / 194
Time to Practice! / 195

16. Windows and Frames 197


Frames and JavaScript / 197
Windows and JavaScript / 201
Assignments / 206
One Last Funny Example / 206

17. String Manipulations Revisited 209


Overview / 209
New Basic String Methods / 209
Regular Expressions in JavaScript / 210
Regular Expressions in PHP / 213
The Set of PCRE / 214

18. JavaScript and DHTML 217


Overview / 217
Positioning Elements / 217
Writing Dynamic Menus in DHTML / 222
Your Turn!! / 225

19. Putting It All Together! 227


Overview / 227
Procedure / 227
Step I-Understanding the Problem and Finding the
Solution / 227
Step 2-Designing the Database / 228
Step 3-Main Functionalities / 230
Step 4-Backside / 231
Step 5-Improvements on Functionality / 231
Step 6-Improvements on Looks / 232
Step 7-Thorough Testing, Hacking Attempts / 232
Step 8-Presentation / 233
Step 9-Publication / 233
Step IO-Celebration © (and Maintenance) / 234
What Language to Use? / 234
xli CONTENTS

Appendix A: Special Characters 237

Appendix B: Installing on UNIX 241


Overview / 241
Installing Apache and PHP / 241
Installing MySQL / 243

Appendix C: Advanced phpBB 247

Appendix D: class.FastTemplate.php 251

Appendix E: File Upload Script 267

Bibliography 269

Index 271
Preface

ABOUT THE AUTHOR

Steven Gabarr6 was born in 1979 and raised in Alicante, Spain. He started
programming early, learning BASIC (Beginner's All-purpose Symbolic
Instruction Code) at age 9. Later on, in high school, he learned Turbo Pascal
and C. At that point it was pretty obvious that he was going to end up as a
computer scientist. He ended up studying for a master's degree in computer
science in the Ecole Pour l'Informatique et les Techniques Avancees, where
he specialized in advanced multimedia and Web technologies, graduating
with honors, finishing third in his class. He went to the United States in
January 2002, enrolling in the Masters of Science in Information Systems at
the Stevens Institute of Technology, in Hoboken, New Jersey. There he quickly
advanced from teaching assistant to full-time instructor. On his appointment
as full-time faculty, he created the first Web programming course at Stevens,
based on his personal experiences. This book is the result of that course, and
is a close reflection of what Steven teaches his students.

BEFORE WE GET STARTED

In my years of programming, I have learned tons of different programming


languages, ranging from Basic to Java, and including C, PHP, JavaScript,
Visual Basic, C++, Assembly 68k, and many others. Because of this variety I
have always been obsessed with utilizing the tools I had available to combine
the best aspects of each programming language.
xiii
xiv PREFACE

With this mentality I decided to create a Web programming course


that would teach the ins and outs of the most commonly used free Web tech-
nologies. I have always supported free software, and as the big UNIX fan that
I am, I had to teach open-source technologies. This book is the result of the
work I did on the course, with added content to take it a step further.

WHO SHOULD READ THIS BOOK?

The way this book is organized, it should be ideal for anyone trying to learn
how to create complete Websites with no previous knowledge of any of the
languages presented. It does require some minimum knowledge of program-
ming in general, as well as object-oriented programming basics to understand
Chapter 8.
It is also a good read for Web designers that know about making pages
look nice, but have no knowledge of how to create dynamic pages built
through a database or anyone who would like to pick up on the art of pro-
gramming pages. Realize: that I have never been a good graphic designer, so
this book will not tell you how to do things like making decisions regarding
the proper colors, fonts, or sizes to use, or other cosmetic details. I will deal
with how to set those features up, but will not tell you how to pick your layout
or color schemes, because I am definitely not good at it. Instead, I will con-
centrate on how to actually program useful pages with loads of functionality.

ABOUT THE EXAMPLES

All the examples have been tested, and if any are not compatible with a spe-
cific browser, this will be stated in the text. You can find all the example files,
as well as an example solution for the mini exercises and the indexer/searcher
case study at ftp://ftp.wiley.com/public/sci_tech_med/web_application. I will
also work on extra examples that I will make available to illustrate other areas
of the book that did not get a full example. I would have included many more
examples, but then you would need two or three volumes this size. Instead, I
will just put everything in a Website for you to download and test. I hope you
enjoy it all!

HOW TO READ THIS BOOK

The book is organized to be read front to back, but you may skip chapters as you
see fit, or use the book as a reference. The Introduction is a summary of Chapter
19 and should be used by people already experienced in Web development. It is
basically meant as a guide to using this book as a "Web programming cook-
book." You may read this Introduction for brief guidelines or go straight to
Chapter 19 if you need an in-depth explanation with a practical example.
Acknowledgments

I'd like to express great thanks to my family first for always being there for
me. I wouldn't be where I am without them, and I'll never manage to thank
them enough for that. To my very close (and special, a.k.a. N.B.) friends, I
thank you for your support and patience over the years; it is not easy putting
up with me for so long, but you have always given me some of the best times
I could hope for. Quick "howdy" to my online friends at COTW and BF2C
for helping me steam off when I had too much work and needed a break.
Thanks to Larry Bernstein for allowing me the opportunity to write this
book, and of course thanks to the people at John Wiley & Sons for getting
my first book published even though I'm still "a kid." Special thanks to
Whitney, Paul and Melissa for all of their help and patience; and to Ben for
the cover image. ©

xv
Introduction

Web Application Recipe

OVERVIEW

You might be wondering why you are reading an "Introduction" chapter and
why this chapter is called "Web Application Recipe." Well, this chapter is
your quick guide to professional Web application design and implementation.
It is in essence a summary of the last chapter of the book (Chapter 19),
created mainly for people with enough experience in Web programming to
skip some of the chapters presented. This chapter will give you the rundown
of the major steps in the lifecycle of a Web project, and will refer to the chap-
ters where you might find more in-depth information on the topics covered.
I call it the "recipe" because it gives you the general layout of what needs to
be done, before getting into the specific details that each individual chapter
will cover. For a more in-depth guideline with a practical example, be sure to
read Chapter 19.

PROCEDURE

Step 1-Understanding the Problem and Finding the Solution


The first step in Web development (and any type of project, to be honest) is
to understand what the problem is, as well as what input will be used and

Web Application Design and Implementation: Apache 2, PHP5, MySQL, JavtiScript, and
Linux/UNIX, by Steven A. Gabarr6
Copyright © 2007 by John Wiley & Sons, Inc.

1
2 WEB APPLICATION RECIPE

what output should be produced. This phase is usually done in meetings


between the project manager and the project sponsor (the person paying for
the project). This is a crucial phase as it defines the scope of the project, such
as the features that need to be implemented, and the feel that the page should
have. The main area of discussion in this step is what the project will do,
without concentrating on the "how."

Step 2-Designing the Database


When creating web applications, chances are your program will need to store
data; hence the use of databases. Many developers create the database as they
implement the program, but this can cause serious troubles as they realize
well into the project that: the initial design of the database is flawed and all
the work needs to be redone. This is why you should always start by designing
the database, keeping in mind what the project needs are. Chapters 11 and
12 will show you how to design and create a database. In a database-driven
project the database is the heart of the project.

Step 3-Major Functionalities


Once the database is created, it is time to program the major functionalities
of your application. Many programmers tend to spend a lot of time making
sure that the pages they create look good, without worrying about whether
they actually do something. Webpage appearance is obviously important, but
you will get more out of an ugly functional Web application than with a pretty-
looking useless page. Most of the work needed in this phase will require
accessing the database. To find out more about how to do so, check Chapter
13. This step is basically like programming the brain of your application,
ensuring that its core runs perfectly well.

Step 4-Backside
Once the core of the project is up and running, you need to implement the
back end of the project. This is the section of the project that will be used by
administrators to manage the Website after it has been published, and it is a
good idea to have it up and running before the regular users start meddling
with the Web application. If you need some information on writing scripts in
PHP, check out Chapters 5-9.

Step 5-lmprovements on Functionality


This is the phase where you start having fun with the project and improve
its functionalities. It is the opportunity to begin improving the client-side
functionalities by adding some JavaScript scripts to your pages, such as form
PROCEDURE 3

verifications. Check Chapters 14-18 for more information on how to program


in JavaScript. Just make sure that the improvements you decide to work on
are within the scope of the project, to avoid what is known as "scope creep"
(see Chapter 19).

Step 6-lmprovements on Looks


Once your project is working, you may start working on the esthetics. Start
by using style sheets (Chapter 10), and do not hesitate to ask your favorite
Web designer for help. In case you wonder about the difference between
a web developer and a Web designer, in essence, a Web designer takes
care of the looks (appearance) of Websites and Web developers write the
scripts that make the pages work. This is the step that adds the skin to the
project.

Step 7-Thorough Testing, Hacking Attempts


This is probably one of the most important phases in the project. The goal of
this phase is to ensure that the project is flawless and that you have made it
hackerproof. The best asset in this phase is imagination and a bit of paranoia.
Never assume that your users will be friendly, using your application for what
it was meant to be. The true secret to a hacker-safe program is to think like
a hacker. Try to think of any security hole that you might not have fixed yet
and fix it! This step is the equivalent of getting some immunizations for your
project. The more time you spend here, the less time you will spend dealing
with attacks.

Step 8-Presentation
Assuming that you are not writing the application for yourself and there is
money involved, you will need to present your final project to your project
sponsor. The key here is to be relaxed and be confident that your project
is rock-solid. If you follow the guidelines in this book, this should not be
a problem. If you are presenting to a nontechnical person, start by showing
the general features of the project, getting into details only when asked to
do so. If you are presenting to a fellow developer, go straight to the
functionalities.

Step 9-Publication
When the project has been approved, it is time to release it. Place it in your
desired host and make sure that everything is set up properly so that users
worldwide can access it. This phase should be fairly fast.
4 WEB APPLICATION RECIPE

Step 10-Celebration (and Maintenance)


Once the project is published, this is your chance for a small break. Enjoy
your favorite brew, have a good night's sleep, and get back to work! Once a
project is published, you need to maintain it, updating the database as needed
or fixing bugs that users might have found.
1
Fundamentals

THE ORIGINS OF THE INTERNET

Not that long ago, in a galaxy pretty close by, men and women used to live
without practical means of communication. Paper was the main medium used
for information sharing and horses the main carrier for that medium. But
science kept working, and in 1831 Joseph Henry invented the first electric
telegraph. Four years later, Samuel Morse invented the Morse code, and
worked on the very first long-distance electric telegraph line, which he fin-
ished in 1843. A bigger leap in communication progress was made by Alex-
ander Graham Bell, who patented the electric telephone in 1876.Long-distance
communication was finally a reality, but still archaic compared to what was
to be achieved. With the arrival of computers in the midtwentieth century,
people realized the potential of storing and processing data in those amazing
new machines. Furthermore, the United States and the Soviet Union were
deep in the Cold War, and the fear of a possible strike was constantly present
in the military's mind. One of the main concerns was the possibility that all
communication between remote locations could be interrupted by an attack.
Telephone and telegraph lines were out in the open, and could be easily
damaged, so the National Security Agency (NSA) thought of a way to
preserve communications. Emulating the principles of telephone commu-
nication, in the 1960s, the NSA thought of connecting computers through

Web Application Design and Implementation: Apache 2, PHP5, MySQL, JavaScript, and
Linux/UNIX, by Steven A. Gabarr6
Copyright © 2007 by John Wiley & Sons, Inc.

5
6 FUNDAMENTALS

wide-area networks (WANs), so that if the phone lines went down, they would
still be able to send orders to detachments across the country, through the
use of computers. In order to make this idea a reality, the Advanced Research
Project Agency (ARPA) created the first computer network in 1969, and
named it the ARPANET. It was composed of only four computers, located
in the University of California at Los Angeles (UCLA), the University of
California at Santa Barbara (UCSB), the University of Utah, and the Stan-
ford Research Institute (SRI). Three years later, in 1972, the use of routers
allowed the ARPANET to have 20 nodes and 50 host computers, which could
all communicate through tools such as the tel net and FTP (File Transfer
Protocol). In 1974 Vincent Cerf, from the SRI, and Robert Kahn, from the
Defense Advanced Research Project Agency (DARPA), presented the Trans-
mission Control Protocol/Internet Protocol (TCP/IP) basics, forever chang-
ing the waycomputers would communicate. In 1983the Defense Communication
Agency (DCA) took control of the ARPANET and separated the military
section to form the MILNET, which would be used for military purposes only.
In the mid-1980s the two main existing networks, the ARPANET and the
NSFNET (created by the National Science Foundation), merged to create a
massive computer network. That merge motivated a trend that brought more
and more computers to the network, and this network of networks was then
named "the Internet." By 1990 the Internet had 3000 subnets and over 200,000
host computers. The estimated number of host computers in the year 2004
was approximately 234 million, and growing.

THE WORLD WIDE WEB

After creation of the Internet, great potential could be seen way beyond the
actual work that was being done. Computers were destined to do more than
utilize telnets and FTP; it was great to be able to link one computer to
another in order to send files, but the problem of communication was not yet
totally solved. Scientists doing research had to connect to a remote computer
and send their research results one at the time through FTP. This was faster
than sending manuscripts through "snail mail," but it was still not the best
option, so in 1989 Tim Berners-Lee presented the World Wide Web project
to the Conseil Europeen de Recherche Nucleaire (CERN; European Orga-
nization for Nuclear Research, based in Switzerland). The idea was to come
up with a set of standards for information sharing that scientists. around the
world would be able to use. The goal was to be able to have all research
documents in a format and location accessible to all interested regardless of
the platform being used . In 1994 the World Wide Web Consortium (W3C)
was created to lead the World Wide Web (WWW) to its full potential by
developing common protocols that would promote its evolution and ensure
its operability. You can find out more about the W3C visiting their Website,
www.w3c.org.
THE WEB SERVERS 7

THE WEB BROWSERS

Right at this point we have seen what lead to the creation of the computer
network known as "the Internet," and the reasoning behind the apparition of
the World Wide Web. But we still have a main problem that we haven't
answered yet-how do we use all this to communicate? First the Internet
brought us the media through which the information would flow, then the
WWW provided a standard format for information formatting, but there
was still the problem of how to read that information. To solve that problem,
some tool had to be created that would use the current standards and decode
Web documents and format them in such a way that would be intelligible
to the user. The Web browsers came to the rescue and solved that pro-
blem. The first graphical user interface (GUI) with the WWW to appear
was Mosaic, created by the National Center of Supercomputer Applications
(NCSA) at the University of Illinois in 1993. In 1994 Norway entered in
the pages of Internet history by creating the still-used Opera. Soon after-
ward Netscape appeared, followed by Microsoft's Internet Explorer, which
appeared along Windows 95. From that point on, the browsing market
has done nothing but evolve and-Fortunately for us, the users-improve.
Nowadays the two main browsers used are Internet Explorer and Mozilla
Firefox.

THE WEB SERVERS

Now that we know what the Internet is, the purpose of the World Wide Web,
and why we use Web browsers, another question may arise: "Where are all
these data stored?" It is definitely enlightening to know how we access all the
information that the World Wide Web has to offer, but where is all that infor-
mation? Well, the answer is pretty simple; it is in all the computers that form
the Internet. Some people become alarmed, believing that any computer con-
nected to the Internet will automatically make all of its files accessible to the
entire world. Not to worry, that is not how it works. In order to share informa-
tion in a specific computer, some software has to be installed on the computer,
making it a "Web server." The server creates a list of folders that will be
shared when someone attempts to connect to the computer using standard
Web protocols. There are two main competitors in the Web server market.
The first one, my personal favorite and the one used throughout this book, is
Apache, developed by the Apache Software Foundation (www.apache.or~).
Apache has the great advantage of being totally free of charge and works on
every platform. It is an open-source program, which means that you can actu-
ally see the code behind the server and even participate in the improvement
of Apache. It is reliable and vastly used around the world, and pretty much
the only reliable option on UNIX/Linux. The other main server is Microsoft's
Internet Information Services (lIS, www.microsoft.com/iis). lIS is not open-
8 FUNDAMENTALS

source and works only on Windows operating systems, although a simplified


free version is available with Windows XP Professional. The latest versions
of lIS run on Windows Server 2003, which obviously is not free. Some of the
differences between lIS and Apache reside in their user interface. Apache,
as most UNIX-based software, is configured entirely through a simple text
file that is loaded when the server starts up, whereas lIS has a GUI that is
meant to be much more user-friendly. Choosing which server to use is based
mainly on knowing which technologies will be used as well as the budget
available. Users on a low budget will probably prefer the use of open-source
technology and free development platforms; hence the use of Apache. If, on
the other hand, you wish to use Microsoft's .NET and you have the money to
afford it, lIS is the best option.

TCP/IP BASICS

As mentioned earlier, the Internet was strongly enhanced by the creation of


TCP/IP by Cerf and Kahn, but how exactly did TCP/IP help in this new era
of communications? When studying network communications, we learn about
the Open Systems Interconnection (OSI) layer model. This model breaks
down all computer networking into seven distinct layers. Computers can com-
municate at the same level through a set of protocols adapted to that particu-
lar layer. The seven layers are as follows (in ascending order):
1. Physical layer-responsible for sending raw bits over the communica-
tion channel. It is specific to the medium [twisted-pair or fiberoptic
cable, wifi (wireless fidelity), etc.].
2. Data link layer-takes a raw transmission and transforms it into a line
free of undetected transmission errors. It also breaks the input data into
data frames and transmits them sequentially. Finally it attaches special
bit patterns at the beginning and end of the frame like the starting frame
delimiter (SFD), cyclic redundancy check (CRe), or the preamble. This
is the layer responsible for flow control and error control.
3. Network layer-concerned with addressing and routing of messages to
their respective final destinations.
4. Transport layer-·provides services that support reliable end-to-end
communications, such as generating the final address of the destination,
establishing the connection, error recovery, and termination of the
session.
5. Session layer-responsible for the dialog between two cooperating
applications or processes. Remote login and spooling operations use the
session layer to ensure successful login and to control the flow of data
to the remote printer. The token management in a token ring configura-
tion is handled by the session layer.
TCPIIP BASICS 9

6. Presentation layer-concerned with the syntax and semantics of the


information transmitted from end to end. For example, X Windows is
considered a level 6 service.
7. Application layer-provides the utilities and tools for application pro-
grams and users, like telnet, FTP, DNS, and HTTP.

TCP/IP is basically a simplification of the OSI layer model that concen-


trates on only four layers: network access layer (Ethernet, FDDI, or ISDN),
Internet layer (IP), transport layer (TCP, UDP), and application layer (FTP,
telnet, SMTP, HTTP).

The Internet Layer


The Internet layer is the equivalent of the network layer in the OSI model. It
contains the Internet Protocol (IP), which provides addressing, datagram
services, data package segmentation, and transmission parameter selection.
In order to function properly, TCP/IP relies on IP addresses, which are
assigned to each computer. An IP address is composed of 4 bytes, and is
usually shown as four numbers separated by dots. Each of these numbers can
range between 0 and 255, since it represents only one of the bytes of the IP
address (and, as you should know, you can represent 256 numbers with only
8 bits). Each IP address is composed of two parts, the network address and
the computer address. To understand how the address is broken down, you
need to know your subnet mask. The way it works is through a basic binary
AND operation between your address and your subnet mask. The result of that
operation represents the network address. For example, let's assume that your
IP is 192.168.1.20, and your subnet mask is 255.255.255.0. Let us see how we
get the network address:
If you are not sure about how to use the binary AND with nonbinary
numbers, start by transforming each number to binary. 192.168.1.20 becomes
11000000.10101000.00000001.00010100, and 255.255.255.0 is 11111111.11111
111.11111111.00000000. Performing the AND operation between those two
numbers gives us 11000000.10101000.00000001.00000000, which is no other
than 192.168.1.0. You can achieve this result faster by realizing that 255 in
binary is written 11111111, and since an AND operation between a 1 and any
other bit will leave the bit unchanged, we can basically keep the numbers of
the IP address that correspond to the 255s of the subnet mask. Then we know
that a binary AND between 0 and anything will always be 0, so where our
subnet mask is 0, we can directly write o. So, if we have an IP of 155.180.24.45
and a subnet mask of 255.255.0.0, our network address will be 155.180.0.0.
This network address lets us know which computers we will be able to
communicate with directly. Only computers that are in the same network can
"see" each other, so a computer in a 192.168.1.0network and another one in
a network 155.180.0.0 will not be able to communicate with one another even
if they are directly linked to each other. The rest of the IP address (20 in the
10 FUNDAMENTALS

first example, 24.45 in the second) corresponds to the particular computer


address. Choosing a network appropriately is important since it will decide
the amount of computers that you can connect. For instance, a network with
a subnet mask of 255.255.255.0 will be able to accommodate only 254 distinct
IP addresses. This type of network is said to be of class C. A network with
subnet of 255.255.0.0 is said to be of class B, and finally 255.0.0.0 will be
subnet of a network of class A. One of the most important things when choos-
ing your computer's IP address is making sure that it is a valid address. You
are not allowed to have an IP that is the same than your network address; for
example, if your network is 192.168.1.0, you cannot have 192.168.1.0 as a
computer's IP address. The other restriction is that your computer address
cannot be all ones in binary; for instance, in the same network as in the previ-
ous example, the address 192.168.1.255 is not authorized (as 255 is 11111111
in binary). This type of address is used by TCP/IP to send broadcast messages
to all computers within the network.
Now that we know how the IP address work, you might be wondering how
you can be in a class C network (with a maximum of 254 computers) and still
be able to access millions of computers worldwide, even though they are not
in the same local network as you are. Well, the answer to that is basically the
use of routers. Routers are small machines that act as a bridge between two
separate networks. To function, they have two network cards in two separate
networks. For example, you could have a router with one of its IP addresses
as 192.168.1.254 in a class C network, and the other IP as 155.180.255.254 in
a class B network. If a computer connected to the class C network attempts
to access an IP that is not part of the 192.168.1.0 network, it sends the IP
requested to the router, which will then try to find that address using its
second branch. The whole principle of the Internet is based on millions of
networks connected through routers. Now, because of the amount of routers
in the world, there is a virtually infinite amount of ways to submit data
between two computers. To avoid taking the wrong path, several protocols
can be used.
Remembering the IP addresses of all the possible computers we would like
to access is pretty difficult, so symbolic addresses were created. Those
addresses work as a set of aliases of real IP addresses, such as .com, .gov,
.net, .es, and .co.uk. To make it even easier, it is possible to assign a name to
a specific address, such as google.com, for example. In order to retrieve the
corresponding IP, the computer accesses something called a Domain Name
Service (DNS), which contains a table with all equivalences between names
and IPs. Every time you see a dot in a name, this means that you are accessing
a subdomain; for example, if you visit the page http://steven.bewchy.com/, you
are looking within all companies (.com) for the one called "bewchy," and once
you find it, you look for the subdomain called "steven" within "bewchy." The
''http://'' section allows the computer to know that you wish to access that
domain using the HTTP protocol. DNS is another protocol residing in the
Internet layer.
TCPIIP BASICS 11

The Transport Layer


The transport layer is home to two main protocols: the User Datagram
Protocol (UDP) and the Transmission Control Protocol (TCP). UDP is a
connectionless protocol, meaning that the order in which messages are sent
by the emitting computer is not necessarily the order in which they will be
received in the destination computer. This protocol is not of interest in this
book, so we will not go any further in the explanation of UDP. TCP, on the
other hand, is very important for Web access; it is a connection-centered
protocol. TCP handles the connection, disconnection, data flow control and
transfer, sequencing, and many other tasks required to establish a proper
communication between two computers. It receives the data flow that needs
to be sent by the user and breaks it down into packets of usually 64 kB (kilo-
bytes; i.e., 65,536 bytes), which are then sent through the IP protocol. In order
to send those packets, TCP needs to open something called a "socket," which
is a couple of the type <IP address, port> which can be used by programs to
access files. Sockets can be opened or closed, and allow both reading and
writing. For example, a character in a TV show who asks the computer techni-
cian to "open a socket on a computer" is actually requesting access to the
computer through its IP address on a specific port. You can imagine "ports"
as electronic gates that reside within your computer and that are needed to
send or receive information. For example, when you access a Webpage, the
information contained in the page is sent to you via your port 80 (generally).
If you access an FTP server, you are using your port 21; if you are connecting
through SSH (Secure SHell; used to connect to remote computers), you're
probably using port 22.

The Application Layer


This layer is responsible for the protocols that most users know or at least have
heard about. The first and uttermost important for this book is the HyperText
Transfer Protocol (HTTP). HTTP was created for the exchange of HTML
documents; it is based on TCP/IP and is the protocol responsible for the com-
munication between Web server and Web client (you and your browser!). This
protocol is meant to be multiplatform, so everything is sent in ASCII (Ameri-
can Standard Code for Information Interchange) format, as plain characters.
We shall talk more about HTML documents in the next chapter.
Many other protocols in the application layer are important in the everyday
life of an Internet user, such as the following ones:
• File Transfer Protocol (FTP)-responsible for transferring files.
• Simple Mail Transfer Protocol (SMTP)-responsible for sending emails.
• Post Office Protocol (POP)-usually seen as POP3 by email clients.this
protocol allows you to retrieve email messages from your mail server.
• Internet Message Access Protocol (IMAP)-another protocol used for
email transfers.
12 FUNDAMENTALS

• Telnet-widely used in the early days of the Internet but fortunately is


now loosing importance. It allows you to remotely connect to a computer,
but the major disadvantage is that it does not encrypt any of the data sent
through this protocol (and that includes your passwords).
• Common Gateway Interface (CGI)-discussed further in the next
chapter; in a nutshell, it allows you to use the output of external applica-
tions in any Webpage. It is not a programming language!!

THE TOOLBOX

To conclude this chapter, I will list some programs that I believe all Web
developers should know about. All opinions are entirely personal, and you
are more than free to disagree with me.

Browsers
As mentioned earlier, browsers are essential in the use of the Internet and
choosing the right one for you is an important decision to make. Throughout
this book we will discuss some of the differences between these browsers,
especially during the JavaScript coverage. The most commonly used by
Microsoft Windows users is obviously Internet Explorer (http://www.micro-
soft.com/ie/), since it comes with the operating system. MSIE is a very user-
friendly browser, and perfect for Mr. or Mrs. Anybody that just wants to
browse the web. As a developer you must know that it is a dangerous tool,
since no matter how disgusting your HTML code might be, MSIE will manage
to make the output look decent, especially when using tables or frames. So
do not assume your page is perfectly written just because MSIE displays it
nicely. One of the advantages of MSIE is that JavaScript works perfectly well
with it, so you will probably love it when we are working on that language. It
also contains many plug-in that are required in many websites, so you might
actually be required to use it to fully appreciate some websites. The major
flaw it has as far as I'm concerned, and a reason why I stopped using it, is the
number of security holes it contains. Granted, in most cases no one will ever
attack your computer using those security holes, but as a computer scientist,
I like being protected.
Another browser that had great influence in the world of browsing is
Netscape (http://browser.netscape.com/ns8/), which had a great growth in the
late 90s. Unfortunately for Netscape, it has been going downhill for few years
now, and personally it will never cross my mind to use it again until they
improve it greatly. I actually stopped using NS when they released their
version 6, mostly due to JavaScript incompatibilities that will be mentioned
in further chapters. But basically Netscape had a set of Netscape-specific
HTML tags that were both useful and necessary for the use of JavaScript on
that browser, but they decided to wipe those out on version 6, which pretty
THE TOOLBOX 13

much was like forcing programmers to reprogram every single JavaScript


code programmed for version 5. When I discovered that, I decided to stop
using Netscape.
Another browser that was quite "cute" for lack of better words was Neo-
Planet (www.neoplanet.com). It was not really a full fledged browser but more
like an add-on for MSIE. Unfortunately it is no longer available for download
in their official website. The fun thing about NeoPlanet was the use of skins and
sounds, which would allow you to have for example a "shaggadelic" skin based
on the movie Austin Powers with nice flashy colors, peace signs instead of the
regular buttons, and the voice of Mike Myers saying "Oh Behave", "Yeah
Baby!" and other catchy phrases from the movie every time you clicked on a
link. There were skins for all tastes, and was definitely the funniest browser I
ever used in my life. It did get boring and repetitive after a while though.
UNIX lovers have been using a browser called Mozilla for quite some time.
It is like a dream come true for UNIX lovers due to its small size, basic
appearance and good functionality. Mozilla evolved and created the Mozilla
Firefox browser (www.getfirefox.com). which I have to say, is my current
browser. It is probably the most secure browser available for free right now,
and has great features like the use of tabs, which allow you to have as many
open websites as you wish on a single browser window. It also has an extensive
set of skins, though I've never really used them. There are many other features
but I'll let you look into it.
Maybe some of you use things like America Online and its built-in browser,
but I'd rather not say what I think about AOL to make sure that I don't offend
anyone. To phrase it very politely, "I, Steven Gabarro, do not like AOL."

FTP
If you are trying to install an FTP server on a Windows machine, I would
have to recommend Serv-U FTP (www.serv-u.com).Itis a great server soft-
ware that will probably allow you to do anything you want to with it. If you
are looking for an FTP server for UNIX, there are so many good, and free,
ones that I won't even bother mentioning them (there was probably one
included in your UNIX/Linux distribution).
If you are trying to get a nice FTP client, one of the most commonly used
(or at least it was when I discovered FTP) is Cute-FTP (www.cuteftp.com).
There are many others free and not free, but my favorite would have to be
LeechFTP, which allows the use of multiple threads, which speeds up the
transfer of multiple files. Unfortunately, the development of LeechFTP has
not been continued for over a year, so there are no really recent (as of 2006)
versions. I still like myoId version, though, since it never gave me any prob-
lems. It would seem (at the time of this writing) that the people working on
LeechFTP are now working on a new client called BitBeamer (www.bit-
beamer.com). I have never tried that software, so I cannot vouch for it, but it
is supposed to have all the features that LeechFTP had.
14 FUNDAMENTALS

Email Clients
One of the most widely used email clients is Outlook Express, which comes
standard with every copy of Windows (since Windows 95). It is simple and
works well, and is preinstalled with Windows, so no need to add extra soft-
ware if that is your platform. There is also the more complicated version
called Outlook, which does all Outlook Express does but adds in a calendar,
nicer agenda, but also heavier software to run. Personally I prefer the Express
version.
Another survivor of the old ages, and the first email client I ever used in
my life, is Eudora (www.eudora.com).Ihaven·tuseditsince19970rso.so I
am not really in a position to tell you how good the latest versions are.
Many users simply like using the clients that come with their browsers,
such as Netscape mail, or directly with Web-based email clients like Hotmail
(www.hotmail.com). or Yahoo (http://mail.yahoo.com), which allow you to
view emails directly on a browser. Personally I'd recommend you use Gmail
(www.gmail.com)createdbythepeoplefromGoogle.Itis by far the best
Web-based email tool I have used in over 10 years of Internet use, and it is
still in its Beta version, so Google can still improve it. The only problem is
that you can create an account only if you are invited to do so by a current
user.
If what you use is lJNIX or Linux, the two main email clients I know
and have used are "Pine" (Program for Internet News & Mail) and "Elm"
(Electronic Mail), but I would have to vouch for Elm. It is a very small simple
application that runs straight from your shell and lets you choose your text
editor. They are both usuallyincludedwith the major UNIX/Linux distributions.

Programming Tools
Whenever you start programming Webpages, you will have to choose which
software to use, and you might think you need a lot of money for licenses and
so on. Well, think again, because you have excellent tools that will be more
than enough to program Websites (and I strongly recommend that you use
these when working with this book). On Windows platform you have two
great tools called Notepad and Wordpad. I personally prefer the first one
because it is much simpler and does not have all the unnecessary things that
Wordpad has. On UNIX you have "vi" and "emacs," which is pretty much
like choosing between Red Sox and Yankees (or between Real Madrid and
Fe Barcelona), since in most cases people that like one hate the other. In my
case it is true: I love emacs and hate vi. But it is only a question of taste.
If you think those tools are too basic for you and you would like to see
some colors in your code when you type it, you might want to choose some-
thing like HomeSite by Macromedia (www.macromedia.com/software/home-
site). It is a simple text editor adapted to Web development, so it recognizes
the syntax and highlights special words and tags. It also allows you to preview
THE TOOLBOX 15

the page and comes with a great tool for the creation of style sheets. Similar
to HomeSite but a bit simpler is UltraEdit (www.ultraedit.com). which allows
you to import or create your own set of syntax rules and colors associated
with those rules.
Another well-known editing tool is Macromedia's DreamWeaver (www.
macromedia.com/software/dreamweaver). The basic way to use Dream-
Weaver is to simply drag and drop the elements you wish to have in the page.
You can also type directly in a "preview" of the page, having DreamWeaver
take care of all the actual coding. Because of this feature, I do not recommend
it for this course, since it promotes laziness, and adds too much useless code.
If you really want to use it, please use the split view and type in the code
directly. (The split view will allow you to see both the preview and code at
the same time).
Finally, we have Microsoft's FrontPage (www.microsoft.com/frontpage).
which is definitely not my favorite tool for Web programming. It creates a
large amount of unnecessary folders and files when you are just trying to
create a simple Website, and adds useless code in the pages that you create.
It might be a great option for people wanting to create a Webpage without
having to understand any of the code, like web designers, for example. If you
are a Web developer, code should be your number one priority, making Front-
Page my last choice. Last, and least, is Microsoft's Word "Export to HTML"
feature, which should be used only by non-Web-savvy people to quickly create
pages from Word documents. It is very problematic, and I discourage its
use.

Other Useful Tools


Finally, there are some tools that are useful for the "cosmetic" part of Web
programming, such as Adobe's PhotoShop and ImageReady (www.adobe.
com/photoshop), probably some of the best image editing software in the
market. They both come as a single bundle, with PhotoShop used mainly for
pictures and ImageReady focused mainly on images for the Web.
Macromedia also offers an array of tools to create animations and facilitate
the design of a Website such as Flash, Fireworks, FreeHand, or Director.
2
The Different
Approaches of Web
Programming
BEFORE WE GET STARTED

Before I head on and start explaining the different languages available in the
Web programming market, let me stress that all the opinions stated are exclu-
sively my personal views. I tend to be very opinionated, but I will try to justify
both my criticism and praises of the different languages presented.

THE BASICS-HTML

The very first programming language that must be mentioned when discuss-
ing Web programming is obviously HTML. The WWW could not be what it
is today if it weren't for this language. The HTML (Hypetrext Markup Lan-
guage) is, as the name indicates, a "markup" language, which generally means
that it is based on the use of tags to provide functionality. The "code" in an
HTML file is simply text containing those tags that provide functionality and
different looks to the page. It is an interpreted client-side language, meaning
that for an HTML page to be viewed, a browser must first download it from
a server into a client machine and then execute the code line by line.
HTML relies strongly on the use of Universal Resource Identifiers (URI).
Each URI represents a way to refer to a page, an image, or even an email

Web Application Design and Implementation: Apache 2, PHP5, MySQL, JavaScript, and
Linux/UNIX, by Steven A. Gabarr6 .
Copyright © 2007 by John Wiley & Sons, Inc.

17
18 THE DIFFERENT APPROACHES OF WEB PROGRAMMING

address. The location of a page is a URI commonly called URL (Universal


Resource Location). For example, an email address URI would look like
mailto:[email protected], a normal URL could be http://www.mydo-
main.com/myfolder/mypage.html#section2. Usually a URL can be of two
types: absolute or relative. An absolute URL is basically a URL that includes
the information on the full path of a file or folder, like domain, subdomain,
file, section, ... A relative URL is one in which you can see not the entire path
of the file, but how to reach it from the current working directory. For example,
if you had the tree structure shown below in your "mydomain.com," and you
were viewing the page "foobar.html," the image mypic.jpg could be accessed
by using either http://www.mydomain.com/images/mypic.jpg (absolute URL)
or ../images/mypic.jpg (lJRL relative to the folder files):

mydomain.com (I)
images

t mypic.jpg
myotherpic.jpg

t
files
foobar.html
otherfile.html
yetanotherfile.html

As you noticed, relative paths usually start with "..1", which means "go to
parent directory" or "'/", which means "current directory." Relative paths
are an easy way to make a Website more portable since they are independent
of the domain that the pages are in. It is especially useful if, like me, you
test all your pages in a local computer before uploading the files to your
host.
The use of URIs is pretty much a necessity in HTML because they allow
you to embed images to a page, send information from a form to a processing
script, create an image map, link to an external style sheet, create frame docu-
ments, cite an external reference, or also refer to metadata conventions to
describe the page.

THE CREATOR-SGML

SGML, or Standard Generalized Markup Language, is a system for defining


markup languages, like HTML. It is a descendant of IBM's Generalized
Markup Language (GML) developed in the 1960s. It relies strongly on the
use of DTDs (Document Type Definitions) to define the syntax of markup
constructs. SGML is not really used on the Web in its full version, but smaller
subsets of SGML are becoming increasingly prevalent in many information
exchange standards.
OTHER SGML-BASED LANGUAGES-XML AND XSL 19

OTHER SGML-BASED LANGUAGES-XML AND XSL

The eXtensible Markup Language (XML) is a simplification of SGML that


relies on the use of tags to organize information in any format that its writer
deems the best. It is a very common language that is at the base of platforms
like .NET. It is used mostly to exchange information through the Web in an
organized manner, making it easy to retrieve information from its files. XML
files are actually interpreted by most browsers nowadays, showing its contents
in a tree format, such as you would see on a file explorer.
Here is an example of an XML file containing information of some games
that I like:

<?xml version="l.O" encoding="ISO-8859-1"?>


<GAMESLIST>
<GAME>
<NAME>Star Wars Galaxies</NAME>
<DEVELOPER>Sony Online Entertainment / Lucas
Arts </DEVELOPER>
<CATEGORY>MMORPG</CATEGORY>
<RELEASED>Summer 2003</RELEASED>
<CLAN>Clan of The Wroshyr</CLAN>
<CHARACTER>Elder Bewchabbacc The Black</CHARACTER>
</GAME>
<GAME>
<NAME>Battleneld 2</NAME>
<DEVELOPER>Electronic Arts / Dice Software</DEVELOPER>
<CATEGORY>FPS</CATEGORY>
<RELEASED>Summer 2005</RELEASED>
<CLAN>lOlst Airborne Division - 160th Special
Operations Aviation Regiment "Night Stalkers"</CLAN>
<CHARACTER>Captain Bewchy</CHARACTER>
</GAME>
<GAME>
<NAME>Pac man - aka Puck-Man</NAME>
<DEVELOPER>Namco </DEVELOPER>
<CATEGORY>Oldie </CATEGORY>
<RELEASED>1980</RELEASED>
<CLAN>Nbuns Team</CLAN>
<CHARACTER>Nica</CHARACTER>
</GAME>
</GAMESLIST>

Because the output produced by browsers when opening a basic XML file
tends to provide too much information, and it does not have a flexible appear-
ance, XSL was created. The eXtensible Style sheet Language is used as a
20 THE DIFFERENT APPROACHES OF WEB PROGRAMMING

perfect complement of XML files, by specifying the appearance that each


section of an XML file should have. It relies on the XSLT (XSL Transforma-
tions), which through a single link of the XSL file on the XML file, will
produce any type of output that the programmer decides to use. It allows a
really quick presentation of the contents of the XML file, with a much nicer
appearance. Note that the XSL file is dependent on the XML file as far as
tags are concerned, but if you have well-formatted XML and XSL files, any
added element to the XML file will still be properly formatted by the XSL.
Here is an example of an XSL file that will allow us to format the previous
XML file:

<?xml version="1.0" encoding="ISO-8859-1" ?>


<html xsl:version="l.O" xmlns:xsl=''http://www.w3.org/1999/
XSL/Transform" xmlns =''http://www. w3. org/1999 /xh tml">
<BODY style="font-family:Arial,helvetica,
sans-serif; font-size: 12pt; background-color: #EEEEEE">
<xsl: for-each select= "GAMESLIST/GAME">
<div style="background-color:grey;color:
white;padding:4px">
<span style="font-weight:bold"><xsl:value-of
select= "NAME"/> </ sl Jan>
by <xsl:value-of select="DEVELOPER"/>
</div>
<div style="Hzargin-left:20px;margin-bottom:lem;font-
size:10pt">
<xsl:value-of select=ICATEGORY"/> game released in
<xsl:value-of select=IRELEASED"/>. I play it with the
<xsl:value-of select="CLAN"/> as
<xsl:value-of select="CHARACTER"/>.
</div>
</xsl : for-each>
</BODY>
</html>

In order to link our .XML file to the XSL file, you would simply add the
following line right after the «Yxml. . . . ?> line of the XML file:

<Zxml-stylesheet type ="text/xsI" href="videogames.xsl" ?>

THE GOOD OLD Java

A language that must be mentioned when studying virtually any program-


ming area is Java. Because of its multiplatform characteristics, this object-
oriented language has been chosen by many developers in the past. The rise
SOMETHING DIFFERENT-JavaScript 21

of technologies such as J2EE (Java 2 Enterprise Edition) or J2ME made the


use of Java a necessity. One problem in using Java in the Web is mostly that
Java applications run as applets embedded in Webpages, not as a working
part of the page itself. Basically, your Java-based Webpages are not really
pages, whose appearance changes depending on the Java code. Instead, the
page itself is like a frame for a full Java application. This means that the code
must be compiled first into "byte codes," which will have to be downloaded
by the client and will start running only after the client has received the entire
program.
Java is currently undergoing some changes and improvements that will
supposedly make it a very strong choice for Web programming, but in my
opinion, it is far from the best option out there. The fact that applets need to
be fully downloaded and then interpreted by a Java virtual machine in the
client's computer makes it slow, and speed is usually a major factor in the
Web. It is also quite complex to use, since it is a full object-oriented program-
ming language, and not really the fastest way to write a scripting page.
I personally do not recommend the use of Java for Web applications unless
you will be working with J2EE or J2ME. If you are attempting any other
project on the Web, I recommend a scripting language instead.

SOMETHING DIFFERENT-JavaScript

Here comes one of the greater sources of confusion among young developers.
Despite the name "JavaScript," this programming language is very different
from Java. First, it is a compact, object-based scripting language, generally
used to develop client-side scripting pages, and sometimes server Internet
applications. In many cases, JavaScript is code that is embedded directly in
the HTML code of a page, to be executed by the client. This means that the
code is downloaded at the same time as is the rest of the page, making it
entirely visible. It is then interpreted line by line at the same time as are the
HTML tags. Again, it is different from Java; some of the major differences
are listed in Table 2.1.

TABLE 2.1 Differences between Java and JavaScript


Java JavaScript
Compiled byte codes are downloaded from Interpreted by the client as it gets
server to the client prior to execution downloaded
Object-oriented; applets consisting of Object-based; uses built-in extensible
classes with inheritance Objects, but there are no classes or
inheritance
Applets distinct from HTML Code integrated with HTML
Variables data types MUST be declared Variables data types are not declared
Static binding; object references must Dynamic binding; object references
exist at compile time checked at runtime
22 THE DIFFERENT APPROACHES OF WEB PROGRAMMING

THE SAVIOR-PHP

Well, you are probably wondering about the title I gave this section, but let
me explain my logic behind it. I am one of those old-school developers who
believe that C language is one of the best programming languages ever,
because of its flexibility and how easy it is to learn. C is a language that, with
a small toolset, can allow you to achieve pretty much anything you wish to
achieve. Well, for me, PHP is pretty much "C for the Web." The syntax is very
similar, with less syntax restrictions, as we will see little by little, but follows
the two concepts of C that I like the most: flexibility and ease of use. It is
really easy to learn; an experienced programmer can pick it up in a couple of
days. Another great asset of PHP is the fact that it runs server-side, meaning
that the code is executed before the client has access to it, but we shall discuss
this later on. Let us talk about the basics.
PHP is a recursive acronym of Hypertext PreProcessor and, as the name
indicates, works like many preprocessors found in other languages. This
means that the code is read line by line and interpreted as it goes, or at least
that was how PHP started. It is an open-source scripting language, so you will
be able to find many sites enhancing its development. It also means that the
PHP project is created and maintained by developers who wish to invest their
free time in making the product better, yet free.
PHP was designed to work for the Web, and its code is embedded directly
in HTML pages, although, as we shall see later, it is possible to separate
HTML and PHP through the use of templates. Interestingly, PHP is not
limited to work on the Web, and can actually be used to create command-line
scripts that you could run from a shell, or even GUI (Graphical User Inter-
face) applications through the use of the PHP-GTK library.
PHP is also designed to work closely with a wide variety of databases,
including Oracle, MySQL, PostgreSQL, ODBC, and Sybase among others,
making it an excellent choice for database-driven Websites, regardless of the
database you wish to use. It also includes an extensive set of libraries that
allows developers to interact with a wide range of other technologies. PHP
developers can write applications that will generate images, PDF documents,
work LDAP authentication servers, communicate with flash animations, and
many other things that unfortunately we will not be able to discuss, since it
would probably take several volumes.

THE RIVAL-ASP.NET'

Active Server Pages (ASP) and now ASP.NET are probably among the major
sources of confusion among developers. ASP used to be an actual program-
ming language developed by Microsoft that worked similarly to PHP; it was
a server-side scripting language, hence the title "the rival." With the arrival
of the .NET platform, ASP.NET received an entirely new meaning, referring
ANOTHER BIG OPTION-Perl 23

to a development platform, rather than an actual programming language; that


is why you will probably see in the markets that teach how to "program in
ASP.net with another programming language." There are many to choose
from, including, for example, Visual Basic.Net. The whole idea is that you can
develop ASP.NET applications in your desired language. It is all based on the
use of the Common Language Runtime (CLR) designed for .NET. It is widely
used with Web services; it is highly efficient and very popular in big corpora-
tions. One main difference from PHP is the fact that it is not open source,
and its development depends exclusively on Microsoft's developer team. This
also means that using it might become quite expensive if you are to work on
the "official" professional version of the developer. I personally like to call
this the "PHP for high class."

THE MYTH-CGI

Now, here is a good source of laughter among recruiters who know about Web
programming. Many people think that CGI (Common Gateway Interface) is
an actual programming language and tend to "beef up" their resumes, adding
it to their list of known programming languages, without really understanding
what CGI is. CGI is a common gateway interface, and is definitely not a pro-
gramming language. It is a standard for interfacing external applications with
information servers, or, if you prefer, a "magical door" that will allow you to
run your normal executable files in a Webpage. CGI applications are executed
in real time, allowing a dynamic output, such as, for example, generating a
Webpage adapted to a set of received inputs. The way it works is simple; you
first write an application in your favorite language and compile it to an execut-
able rename it to "file.cgi" (note that this is technically optional, and many
developers leave script names as "file.exe"; I personally discourage this).
Some of the most common allowed programming languages are etc++,
FORTRAN, Perl, TCL, UNIX Shell script, Visual Basic, and Apple script.
Of course, to make your application more useful for the Web, it is usually
written to receive a set of parameters and produce HTML code that will be
displayed as the page's output on the browser.

ANOTHER BIG OPTION-Perl

Even though I used Perl only when I was a computer science student, and
considering that it is never in my list of languages to use, I have nothing nega-
tive to say about it. Perl is a very powerful programming language, and also
very flexible, if anything, it is more complicated to learn and use than PHP.
It is also open-source, and one of the best options if your application is meant
to work extensively with text manipulation. Some of the most powerful regular
expression tools were created for Perl, and then exported to other languages,
24 THE DIFFERENT APPROACHES OF WEB PROGRAMMING

as we will see when we study PCRE functions in PHP. Websites such as


Amazon.com are partly built in Perl, so you can see that it is not just a little
programming language for small applications. It also has the ability to inter-
face with external CIC++· libraries through the use of XS and SWIG.

THE FUTURE?-C#

C# was a language created to work with .NET as a simple yet powerful object-
oriented programming language, mixing a programming interface similar to
the old Visual Basic, yet having the object-oriented features you could find
in C++. It is Microsoft's answer to Sun's Java. Java became increasingly
popular through J2EE, so Microsoft decided to create a language following
the same principles on their version of the three-tier architecture program-
ming platform, .NET. It strongly relies on XML as information exchange
format, and it is gaining popularity for programming Web services. As do
other .NET languages, it requires code to be compiled, yet it follows the
principle of Java's byte codes, by compiling into a platform-free language,
that will be interpreted by clients.
The reason behind the question mark is that even though C# is a fairly
recent language it is meant to be the flagship in the .NET revolution-or at
least that is what Microsoft representatives were announcing when they pre-
sented .NET. The reality is that its acceptance is still growing, but many .NET
developers prefer relying on older programming languages that they are more
familiar with ..NET is still gaining importance, and who knows, maybe it will
be the most predominant platform for Web services, not only on Microsoft
applications and Websites, but as a more global solution. If that happens,
surely C# will become increasingly popular and will be the first choice of
programming language for new developers.

CLIENT-SIDE VERSUS SERVER-SlOE-WHICH SIDE TO PICK?

As we have seen, most scripting languages are defined as either client-side or


server-side. A client-side program is basically a program that needs to be fully
downloaded by the browser to use it. The code in many cases is embedded in
HTML code, which results in full disclosure of how your program works,
since all users can read it by choosing the "view page source" option in their
browsers. In many cases the code is interpreted by plugins in the client, which
brings us to another problem of client-side applications-they are browser-
dependent. As we will see when studying JavaScript, many features are not
cross-browser, meaning that they can be used only in a specific browser,
sometimes even in a specific version of it. The positive side of client-side
scripting, and the reason for its continued use, is that once the code is down-
loaded, the server has nothing else to do. The client is solely responsible for
MY CHOICES-PHP, MySQL, JavaScript 25

any calculations or actions that might take place, which allows programmers
to create Webpages that will change dynamically as the code is executed.
Server-side applications run in the server, as the term indicates. This means
that when a client attempts to access a script programmed that way, the query
is sent to the server along with any input that the script might need. The script
then runs on the server, utilizing server resources only, and then sends the
final output to the client, who can see only that result, and has no access to
the source code itself. This obviously is a great asset since it protects the code,
which is very important for security reasons. Another great advantage of
having scripts run directly on the server is that you need to worry only
whether the server knows how to run it properly. Unlike the scenario in client-
side applications, the script will run exactly the same way, producing the same
output regardless of the client's platform or browser. On the negative side,
each time you wish to do something dynamic, you must communicate back
and forth between client and server.
Now that we know the differences between both sides, it is generally the
time to choose your preference, by selecting the language to use. Most devel-
opers, and therefore most books out there, tend to choose only one side, but
not me. Even though it is possible to create Websites based on just one tech-
nology, taking advantage of server-side and client-side programming simulta-
neously gives much more flexibility and allows a greater set of functionalities.
Some features run better in client-side, some in server-side, so restricting
yourself to only one will potentially limit your final project. Throughout this
book we will learn when .it is better to use a client-side language such as
JavaScript, or a server-side language like PHP.

MY CHOICES-PHP, MySQL, JavaScript

Now that we have seen some of the most common options that programmers
face when engaging in Web programming, we must choose which technologies
to use. In our case, the choices are obviously known. One question you might
ask is why those choices and not others.
First, we have PHP. It is one of the most powerful and flexible programming
languages for the Web. It is free, is easy to learn (making it ideal for a one-
semester course), and simplifies any database access you might want to use.
JavaScript, although I do not like it as much as a language itself as it is
much more restrictive syntaxwise than PHP, is a really useful programming
language. As we will see, it is important to have a client-side language to
couple with PHP to make our pages more lifelike, dynamically changing
without having to constantly communicate with the server, and JavaScript will
help us fulfill that need.
MySQL, even though we have not discussed it yet, is a free database that
can be installed in any platform, providing a reliable solution for information
handling. It is also extremely easy to use MySQL databases with PHP, which
26 THE DIFFERENT APPROACHES OF WEB PROGRAMMING

will make our job so much easier. My "second best" option for databases
would be PostgreSQL, similar to MySQL with even some extra features, but
again, we shall follow the path of simplicity for this book.
Finally, and pretty much most importantly, these are the languages that I
have been using for years, and I never had any problems with them. Knowing
how to properly mix these three programming languages should allow you to
create any professional database-driven Website you would like to. Also,
although you might use different technologies in the future, mastering these
three will give you the mindset needed for Web development. It is like learn-
ing how to play soccer; you must learn how to kick the ball, regardless of the
shoes you will wear or the team you will support. Web programming is much
the same; if you know how to properly design a Website, the language choice
will be only secondary.
3
Introduction to HTML

WHAT DO YOU NEED TO GET STARTED?

Before we start discussing HTML, let me give you a checklist of things you
should have with you when programming. First, you need a basic text editor
like Notepad or emacs. You can also use more advanced tools, like the ones
mentioned in Chapter 1, but if you really wish to learn the ins and outs of
HTML, you are better off with a basic editor. The next needed thing is a
browser, which will be used to test the pages and make sure that they look
the way you want. Third, you need, obviously, some basic HTML knowledge.
Last but not least, you need good music. People usually think I'm kidding
when I mention music as a necessity, but from my experience, the right music
can activate the brain to work more efficiently. The right music will depend
on your own personal taste, but I would recommend either classical if you
work better in a calm environment or hard rock, punk, and other fast-paced
music if, like me, you prefer the music tempo to drive your fingers into a typing
frenzy. This chapter will try to make sure you have element number three:
basic HTML knowledge.

Web Application Design and Implementation: Apache 2, PHP5, MySQL, JavaScript, and
Linux/UNIX, by Steven A. Gabarr6
Copyright © 2007 by John Wiley & Sons, Inc.

27
28 INTRODUCTION TO HTML.

HOW DOES HTML WORK?

Syntax Basics
HTML is a markup language and, as such, works entirely through the use of
tags. Each tag is used to define different parts of the file, different styles, links,
images, embedded elements, forms, and so on. Each tag starts with the char-
acter "<" and finishes with ">". Keep this in mind because those characters
are restricted for tags, meaning that your page might behave in a strange way
if you attempt to use it in a normal string. If you wish to use that character,
refer to the special characters table shown in Appendix A. Now, some tags
require an opening and a closing tag in order to show the area of effect of the
tag. In those cases the closing tag will always start with "«I", followed by the
name of the tag it is closing (without the attributes list) and ">".
For example, to have some text appearing in white, you could use the
FONT tag, with the attribute color set to "white." To do so, your opening tag
would be <FONT color = "white"> and your closing tag would be </FONT>.
Your final portion of code would look like this:

<FONT color="white"> This text will show up in white</FONT>

Note that HTML is not case-sensitive, so you can mix uppercase and lower-
case letters. Nevertheless, I strongly advise everyone to capitalize all tags
since it makes code reading much easier.
Finally, remember to name your files with either .html or .htm as their
extension.

File Structure
It is very important to understand the basic structure of an HTML file,
knowing exactly where each part of your code must be written in. It is some-
thing fairly easy to remember, but unfortunately there are still people who
claim to be Web programmers but who misuse the file's main areas. Good
Web design and programming demands efficient and effective use of the
available tools. This book is designed to avoid these pitfalls.
The first thing is the full file, which must always start with the tag <HTML>
and finish with </HTMI~>. You should never have HTML tags before the
opening tag, nor after the closing one. One of the reasons for this occasional
error is the fact that most browsers can now ignore major errors like this one
and still manage to create a proper-looking output, but please always start
your files by setting up these two tags.
The next section to know is the header, limited by the tags <HEAD> and
</HEAD>. This section holds all information related to the file, including its
author, its keywords, its title, and sometimes even some JavaScript functions
that will be used in the page. Most basic pages use the header only to specify
HOW DOES HTML WORK? 29

the title that will appear on the browser window.To do so, use the <TITLE> ...
</TITLE> tags. Any text written between the opening and closing tags will
appear in the title bar of the browser.
The final area is the body, starting with <BODY> and finishing with
</BODY>. The body of a page is the actual content of the page, meaning that
the data that will appear inside the browser window. The body tag can accept
a set of properties that allow you to set up a background image (background)
or color (bgcolor); specify font colors for text (color), links (link), visited links
(vlink), active links (alink), and even action scripts to run on load or unload
of the page. There should always be a body section in a Webpage, unless you
are using the page as a frameset definition page (see discussion later).
Here is an example of what a "Hello world" HTML page should look
like:

<HTML>
<HEAD>
<TITLE>Hello World Page</TITLE>
</HEAD>
<BODY>
HELLO WORLD!!! <BR>
And have a nice day!
</BODY>
</HTML>

Note the indentation I have used. This is not required, but will improve the
readability of your code. You will also note the use of the tag <BR>, which
forces a break of line. It is important to realize that any group of white spaces
(whether it is a tab, a new line, or basic spaces) is always translated on the
screen as a single white space. This is important to know since the appearance
your code has will not necessarily be the same as in the output. Check the
following example:

<HTML>
<HEAD>
<TITLE>Hello World Page</TITLE>
</HEAD>
<BODY>
HELLO WORLD!!!
And have a nice day!
</BODY>
</HTML>

You probably noticed that this code is almost exactly the same as the previous
one except that there is no <BR> tag after "Hello World!! L" In this example,
the text "And have a nice day!" would show on the same line as "HELLO
30 INTRODUCTION TO HTML

WORLD!!!," even though it is written a line below it, because the "new line"
will be translated into a single white space.
As a teacher I enforce the use of the basic six tags needed for an HTML
proper structure, so I would recommend everyone to make it a habit to write
them all as soon as a page is created, and then fill in the blanks.

Tag Parameters
As we saw previously with the FONT and BODY tags, it is possible to add
attributes to an opening HTML tag to make it more effective. Each attribute
will affect the area after the opening tag and will finish with the closing tag.
Remember that there is no need to write the attributes in the closing tag.
Checking the W3C website (www.w3c.orG) can get you an exhaustive list of
all the attributes that tags can use, but I will give you the ones I consider most
important for the tags that I will teach you at the end of this chapter.

BASIC TEXT FORMATTING

There are many ways to format text in HTML, but we will discuss only the
real basics right now. There will be more details on styles in Chapter 10. The
tags I am about to show you are considered to be deprecated and should be
replaced with the use of style sheets, but as much as this is true, you probably
want to get started without having to learn advanced formatting features. In
that case, the following tags are ideal.
The first basic tool commonly used for formatting text is the <P> ... </P>
tag, which stands for "paragraph." As the name indicates, it defines an area
that works as a single block, and most browsers will automatically break a new
line at the end of a paragraph. I try not to use this tag when writing normal text
since the output on the screen might be different depending on the browser, so
I prefer to handle my paragraphs manually. On the other hand, paragraphs are
really useful when using style sheets, as we will see in Chapter 10.
A very useful tool in HTML is the different heading styles that can be
used. There are six basic: levels of headings that can be used to easily write
titles, chapters, or sections. Each heading is treated as a paragraph, so a new
line is added automatically when the tag is closed. To use a heading, simply
wrap your title with «Hn» ... <IHn>, where "n" is the level of title you wish
to use from 1 to 6 (with HI the biggest heading and H6 the smallest). If you
wish to add extra linebreaks you can use, as seen earlier, the <BR> tag.
To change the appearance of text, you can use <I» ... <II> to italicize a
text, <B> . . . </B> to make it bold, or <V> . . . <IV> to underline it. As
always, these tags affect the text only between opening and closing tags. It is
also possible to use the <FONT> tag to specify colors, fonts, sizes, and back-
ground colors, for example, but it is considered poor programming practice
to use these in your HTML code since it makes it much more difficult to read.
Instead, you should use styles, which, again, we will see in Chapter 10.
BASIC TEXT FORMATTING 31

Most tags, including <P>, accept an attribute called ALIGN that allows
setting of the horizontal alignment of a block by setting it to "left," "center,"
"right," or "justify." It is also possible to center an area of the page by using
the <CENTER> . . . </CENTER> tag. The advantage of the <CENTER> tag
is that it will act on anything between opening and closing tags, regardless of
the type of element (form input, image, paragraph, button, etc.).
To do a basic enhancement on your page's look, you can use horizontal
rules. These are horizontal lines used mostly to separate sections and para-
graphs. To use it, just write <HR> with any of the following attributes:
ALIGN (left, center, or right), NOSHADE to remove the shade under the
line, SIZE (in pixels) to specify the height of the line, and WIDTH (length
in either pixels or percentage of the page) to specify the linewidth. An example
ofa nice-looking rule could be <HRALIGN=centerSIZE=l WIDTH=75%>,
which would create a line of 750/0 of the page's width, centered in the page,
and with 1 pixel height. Note that this tag does not need to be closed.
Finally, to conclude this set of basic formatting tools, I would have to add
the <BLOCKQUOTE> . . . </BLOCKQUOTE> tag. This tag was created
to be used to quote other people in a text, but it has a nice property. Any
text inside a <BLOCKQUOTE> tag is automatically indented, which is great
for a really fast indentation solution. I personally have used it in the past to
force a blank margin at the beginning of my pages, making the output
cleaner.
Here is an example using all these tags:

<HTML>
<HEAD>
<TITLE>Formatting example</TITLE>
</HEAD>
<BODY>
<BLOCKQUOTE>
All my text will show up with an indentation!
<P ALIGN=right>This is a first paragraph with right
alignment</P>
<P ALIGN=left>And this is a separate left-aligned
paragraph with things written in <I>italic</I>, <B>bold</B>,
<U>underlined</U> and even <U><B><I>all mixed up</I></B></U></P>
<CENTER>
<HR size=l width=75%>
<Hl>Headingl</Hl>
<H2>Heading2</H2>
<H6>Heading6, and like the others I'm centered!</H6>
</CENTER>
</BLOCKQUOTE>
</BODY>
</HTML>
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of Dramatis
Personæ
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: Dramatis Personæ

Author: Arthur Symons

Release date: May 29, 2020 [eBook #62270]

Language: English

Credits: Produced by Laura Natal Rodrigues at Free Literature


(Images
generously made available by Hathi Trust.)

*** START OF THE PROJECT GUTENBERG EBOOK DRAMATIS


PERSONÆ ***
DRAMATIS PERSONÆ
BY

ARTHUR SYMONS

INDIANAPOLIS

THE BOOBS-MERRILL COMPANY

PUBLISHER'S NOTE

Although it would be presumptuous to introduce the work of Arthur


Symons, a word or two about this particular collection may not be
out of place. A number of these essays have appeared in
representative American and English periodicals, but their
preservation here needs no apology as they have already earned a
meritorious place in the bibliography of English criticism. The
publisher believes, also, that the critical reader must realize the
futility of any attempt to correct discrepancies due to the death of
contemporaries, or augmentations to their work, lest the essays as
originally conceived by the author suffer in spirit.

CONTENTS

CONRAD
MAURICE MAETERLINCK
EMILY BRONTË
ON ENGLISH AND FRENCH FICTION
ON CRITICISM
THE DECADENT MOVEMENT IN LITERATURE
THE ROSSETTIS
CONFESSIONS AND COMMENTS
FRANCIS THOMPSON
COVENTRY PATMORE
SIR WILLIAM WATSON
EMIL VERHAEREN
A NEGLECTED GENIUS: SIR RICHARD BURTON
EDGAR SALTUS
RECOLLECTIONS OF RÉJANE
THE RUSSIAN BALLETS
ON HAMLET AND HAMLETS
LEONARDO DA VINCI
IMPRESSIONISTIC WRITING
PARADOXES ON POETS

DRAMATIS PERS0NÆ

CONRAD

"The Earth is a Temple where there is going on a Mystery Play,


childish and poignant, ridiculous and awful enough in all
conscience."

Conrad's inexplicable mind has created for itself a secret world to


live in, some corner stealthily hidden away from view, among
impenetrable forests, on the banks of untraveled rivers. From that
corner, like a spider in his web, he throws out tentacles into the
darkness; he gathers in his spoils, he collects them like a miser,
stripping from them their dreams and visions to decorate his web
magnificently. He chooses among them, and sends out into the
world shadowy messengers, for the troubling of the peace of man,
self-satisfied in his ignorance of the invisible. At the center of his
web sits an elemental sarcasm discussing human affairs with a calm
and cynical ferocity; "that particular field whose mission is to jog the
memories of men, lest they should forget the meaning of life."
Behind that sarcasm crouches some ghastly influence, outside
humanity, some powerful devil, invisible, poisonous, irresistible,
spawning evil for his delight. They guard this secret corner of the
world with mists and delusions, so that very few of those to whom
the shadowy messengers have revealed themselves can come nearer
than the outer edge of it.
Beyond and below this obscure realm, beyond and below human
nature itself, Conrad is seen through the veil of the persons of his
drama, living a hidden, exasperated life. And it is by his sympathy
with these unpermitted things, the "aggravated witch-dance" in his
brain, that Conrad is severed from all material associations, as if
stupendously uncivilized, consumed by a continual protest, an
insatiable thirst, unsatisfied to be condemned to the mere exercise
of a prodigious genius.
Conrad's depth of wisdom must trouble and terrify those who read
him for entertainment. There are few secrets in the mind of men or
in the pitiless heart of nature that he has not captured and made his
plaything. He calls up all the dreams and illusions by which men
have been destroyed and saved, and lays them mockingly naked. He
is the master of dreams, the interpreter of illusions, the chronicler of
memory. He shows the bare side of every virtue, the hidden heroism
of every vice or crime. He calls up before him all the injustices that
have come to birth out of ignorance and self-love. He shows how
failure is success, and success failure, and that the sinner can be
saved. His meanest creatures have in them a touch of honor, of
honesty, or of heroism; his heroes have always some error,
weakness, a mistake, some sin or crime, to redeem. And in all this
there is no judgment, only an implacable comprehension, as of one
outside nature, to whom joy and sorrow, right and wrong, savagery
and civilization, are equal and indifferent.
Reality, to Conrad, is non-existent; he sees through it into a realm of
illusion of the unknown: a world that is comforting and bewildering,
filled with ghosts and devils, a world of holy terror. Always is there
some suggestion of a dark region, within and around one; the
consciousness that "They made a whole that had features, shades of
expression, a complicated aspect that could be remembered by the
eye, and something else besides, something invisible, a directing
spirit of perdition that dwells within, like a malevolent soul in a
detestable body."
"This awful activity of mind" is seen at work on every page, torturing
familiar words into strange meanings, clutching at cobwebs, in a
continual despair before the unknown. Something must be found, in
the most unlikely quarter; a word, a hint, something unsaid but
guessed at in a gesture, a change of face. "He turned upon me his
eyes suddenly amazed and full of pain, with a bewildered, startled
face, as though he had tumbled down from a star." There is a
mental crisis in that look: the unknown has suddenly opened.
Memory, that inner voice, stealthy, an inveterate follower; memory,
Conrad has found out, is the great secret, the ecstasy and despair
which weave the texture of life. A motto from Amiel in one of his
books faintly suggests it: "Qui de nous n'a eu sa terre promise, son
jour d'extase et sa fin en exil?" And the book, Almayer's Folly, his
first, a rare and significant book, is just that. An Outcast of the
Islands has the despairing motto from Calderon, that better is it for a
man had he never been born. Lord Jim is the soul's tragedy, ending
after a long dim suffusion in clouds, in a great sunset, sudden and
final glory. No man lives wholly in his day; every hour of these
suspensive and foreboding days and nights is a part of the past or of
the future. Even in a splendid moment, a crisis, like the love scene of
Nina and Dain in the woods, there is no forgetfulness. "In the
sublime vanity of her kind she was thinking already of moulding a
god out of the clay at her feet. ... He spoke of his forefathers." Lord
Jim, as he dies, remembers why he is letting himself be killed, and in
that remembrance tastes heaven. How is it that no one except
Conrad has got to this hidden depth, where the soul really lives and
dies, where, in an almost perpetual concealment, it works out its
plan, its own fate? Tolstoy, Hawthorne, know something of it; but
the one turns aside into moral tracts, and the other to shadows and
things spiritual. Conrad gives us the soul's own dream of itself, as if
a novelist of adventure had turned Neo-Platonist.
A woman once spoke to me in a phrase I have never forgotten, of
Conrad's sullen subjective vision. Sullen is a fine word for the aspect
under which he sees land and sea; sullen clouds, a sullen sea. And
some of that quality has come to form part of his mind, which is
protesting, supremely conscious. He is never indifferent to his
people, rarely kind. He sees them for the most part as they reveal
themselves in suffering. Now and then he gives them the full price,
the glory, but rarely in this life, or for more than a moment. How can
those who live in suspense, between memory and foreboding, ever
be happy, except for some little permitted while? The world for those
who live in it, is a damp forest, where savagery and civilization meet,
and in vain try to mingle. Only the sea, when they are out of sight of
land, sometimes gives them freedom.
It is strange but true that Conrad's men are more subtly
comprehended and more magnificent than his women. There are
few men who are seen full length, and many of them are nameless
shadows. Aissa and Nina in the earliest books have the fierce charm
of the unknown. In Lord Jim there is only one glimpse of the painful
mystery of a woman's ignorant heart. In Nostromo the women are
secondary, hardly alive; there is no woman in The Nigger of the
Narcissus, nor in Typhoon, nor in Youth. There are some women,
slightly seen, in Tales of Unrest, and only one of them, the woman of
The Return, is actually characterized.
Is there not something of an achievement in this stern rejection of
the obvious love-story, the material of almost every novel? Not in a
single tale, even when a man dies of regret for a woman, is the
woman prominent in the action. Almayer, and not Nina, is the center
of the book named after him. And yet Nina is strange, mysterious,
enchanting, as no other woman is to be. Afterward they are thrust
back out of the story; they come and go like spinners of Destiny,
unconscious, ignorant, turning idle wheels, like the two women
knitting black wool in the waiting room of the Trading Company's
office, "guarding the door of Darkness."
Now, can we conjecture why a woman has never been the center of
any of these stories? Conrad chooses his tools and his materials; he
realizes that men are the best materials for his tools. It is only men
who can be represented heroically upon the stage of life; who can
be seen adventuring doggedly, irresistibly, by sheer will and purpose;
it is only given to men to attain a visible glory of achievement. He
sees woman as a parasite or an idol, one of the illusions of men. He
asks wonderingly how the world can look at them. He shows men
fearing them, hating them, captivated, helpless, cruel, conquering.
He rarely indicates a great passion between man and woman; his
men are passionate after fame, power, success; they embrace the
sea in a love-wrestle; they wander down unsounded rivers and
succumb to "the spell of the wilderness;" they are gigantic in failure
and triumph; they are the children of the mightiness of the earth;
but their love is the love of the impossible. What room is there, in
this unlimited world, for women? "Oh, she is out of it—completely.
They—the women I mean—are out of it—should be out of it. We
must help them to stay in that beautiful world of their own, lets ours
gets worse. Oh, she had to be out of it."
There is Karain, "clothed in the vision of unavoidable success," flying
before a shadow, comforting himself with the certainty of a charm.
There is Kurtz, who returns to barbarism, and Tuan Jim with his
sacrifice of life to honor, and even the dying nigger steersman who,
shot through by a spear, looks once on his master, "and the intimate
profundity of that look which he gave me when he received his hurt
remains to this day in my memory—like a claim of distant kinship
affirmed in a supreme moment." It is with this agonizing clearness,
this pitiless mercy, that Conrad shows us human beings. He loves
them for their discontent, for their revolt against reality, for their
failure, their atonement, their triumphs. And he loves them best
because their love is the love of the impossible; he loves them
because they are part of the unknown.
And so, it is Lord Jim in which his genius has attained its zenith with
Karain and Heart of Darkness close after it. Consider the marvelous
art, the suspense, the evasion of definite statement, the
overpowering profundity of it. To begin with, there is the trick, one
of Conrad's inextricable tricks of art, by which suspense is scarcely
concerned with action, but with a gradually revealed knowledge of
what might have happened in the making of a man. Take an
instance in Nostromo. There is Doctor Monyngham who comes in at
the beginning of the book comes and goes briefly up to the three
hundredth page; and then suddenly, à propos of nothing, the whole
history of his troubles, the whole explanation of what has seemed
mysterious to him, is given in four pages; whereupon the last
sentence, four pages back, is caught up and continued with the
words: "That is why he hobbled in distress in the Casa Gould on that
morning." Now why is there this kind of hesitation? Why is a disguise
kept up so long and thrown off for no apparent reason? It is merely
one of his secrets, which is entirely his own; but another of them he
has learned from Balzac: the method of doubling or trebling the
interest by setting action within action, as a picture is set within a
frame. In Youth the man who is telling the story to more or less
indifferent hearers, times his narrative with a kind of refrain. ... "Pass
the bottle," he says whenever a pause seems to be necessary; and,
as the tale is ending, the final harmony is struck by an unexpected
and satisfying chord: "He drank.... He drank again."
To find a greater novel than Lord Jim, we might have to go back to
Don Quixote. Like that immortal masterpiece, it is more than a
novel; it is life itself, and it is a criticism of life. Like Don Quixote,
Lord Jim, in his followings of a dream, encounters many rough
handlings. He has the same egoism, isolation, and conviction; the
same interrupting world about him, the same contempt of reality,
the same unconsciousness of the nature of windmills. In Marlow, he
has quite a modern Sancho Panza, disillusioned, but following his
master. Certainly this narrator of Jim's failures and successes
represents them under the obscure guidance of "a strange and
melancholy illusion, evolved half-unconsciously like all our illusions,
which I suspect only to be visions of remote unattainable truth, seen
dimly." He is a soul "drunk with the divine philtre of an unbounded
confidence in himself." That illusion is suddenly put to the test; he
fails, he goes into the cloud, emerges out of it, is struck gloriously
dead.
In Lord Jim Conrad has revealed, more finally than elsewhere, his
ideal: the ideal of an applauded heroism, the necessity of adding to
one's own conviction the world's acceptance and acclamation. In this
stupendous work, what secret of humanity is left untold? Only told,
is too definite a word. Here is Conrad's creed, his statement of
things as they are:

It is when we try to grapple with another man's need that we


perceive how incomprehensible, wavering, and misty are the
beings that share with us the sight of the stars and the warmth
of the sun. It is as if loneliness were a hard and absolute
condition of existence; the envelope of flesh and blood on which
our eyes are fixed melts before the outstretched hand, and
there remains only the capricious, unconsolable, and elusive
spirit that no eye can follow, no hand can grasp.

"Man is amazing, but he is not a masterpiece," says some one in the


book, one of the many types and illustrations of men who have
fallen into a dream, all with some original sin to proclaim or conceal
or justify, men of honor, tottering phantoms clinging to a foul
existence, one crowding on another, disappearing, unrealized. All
have their place, literally or symbolically, in the slow working-out of
the salvation of Tuan Jim. Amazing they may be, but Jim
"approaching greatness as genuine as any man ever achieved," with
the shame of his "jump" from a sinking ship and his last fearless
jump "into the unknown," his last "extraordinary success," when, in
one proud and unflinching glance, he beholds "the face of that
opportunity which, like an Eastern bride, had come veiled to his
side": amazing he may be, but a masterpiece, proved, authentic,
justifying Man.
Next after this triumph, Karain is the greatest. It is mysterious, a
thing that haunts one by its extreme fascination; and in this, as in all
Conrad, there is the trial of life: first the trial, then the failure, finally
(but not quite always) the redemption. "As to Karain, nothing could
happen to him unless what happens to all—failure and death; but his
quality was to appear clothed in the illusion of unavoidable success."
And on what a gorgeous and barbaric and changing stage is this
obscure tragedy of the soul enacted! There is in it grave splendor. In
Conrad's imagination three villages on a narrow plain become a
great empire and their ruler a monarch.
To read Conrad is to shudder on the edge of a gulf, in a silent
darkness. Karain is full of mystery, Heart of Darkness of an unholy
magic. "The fascination of the abomination—you know," the teller of
the story says for him, and "droll thing life is." The whole narrative is
an evocation of that "stillness of an implacable brooding over an
incalculable intention," and of the monstrous Kurtz who has been
bewitched by the "heavy mute spell of the wilderness that seems to
draw him to its pitiless breast by the awakening of forgotten and
brutal instincts, by the memory of gratified and monstrous passions;
and this alone had beguiled his unlawful soul beyond the bounds of
permitted aspiration." And it all ends with the cry: "The horror! The
horror!" called out in his last despair by a dying man. Gloomy,
tremendous, this has a deeper, because more inexplicable, agony
than the tragedy of Karain. Here, the darkness is unbroken; there is
no remedy; body and soul are drawn slowly and inevitably down
under the yielding and pestilent swamp. The failure seems
irretrievable. We see nature casting out one who had gone beyond
nature. We see "the meanness, the torment, the tempestuous
anguish of a soul" that, in its last moment of earthly existence, had
peeped over the edge of the gulf, with a stare "that could not see
the flame of the candle, but was wide enough to embrace the whole
universe."
With Nostromo we get a new manner and new scenery. The scene is
laid in Colombia, the Nuevo Granada of the Spaniards, and the silver
mine is its center, and around that fatal treasure-house the whole
action moves. The Spanish streets, glittering with heat, with their
cool patios, peopled by the Indians, the "whites," a cross between
Spanish and native, the Italians, the English, the Indian girls with
long dark hair, the Mozenitas with golden combs, are seen under
strong sunlight with a vivid actuality more accentuated than in any
other of Conrad's scenes. A sinister masquerade is going on in the
streets, very unreal and very real. There is the lingering death of
Decoud on a deserted island ("he died from solitude, the enemy
known to few on this earth, and whom only the simplest of us are fit
to withstand"); the horrible agonies of Hirsch; the vile survival of
Doctor Monyngham. It is by profound and futile seriousness that
these persons and events take on an air of irony, and are so comic
as they endure the pains of tragedy.
This strange novel is oddly constructed. It is a narrative in which
episode follows episode with little apparent connection. The first half
is a lengthy explanation of what the second part is to put into action.
It drags and seems endless, and might be defined by a sentence out
of the book, where some one "recognized a wearisome
impressiveness in the pompous manner of his narrative." Suddenly,
with Nostromo's first actualized adventure the story begins, the
interest awakens, and it is only now that Nostromo himself becomes
actual. He has been suggested by hints, indicated in faint outline.
We have been told of his power and influence, we see the
admiration which surrounds him, but the man walks veiled. His
vanity, evident at the first, becomes colossal: "The man remained
astonishingly simple in the jealous greatness of his conceit." Then,
as he awakens one morning under the sky, he rises "as natural and
free from evil in the moment of waking as a magnificent and
unconscious wild beast." The figure greatens in his allegiance to the
shining spectre of the treasure, which makes him afraid because "he
belonged body and soul to the unlawfulness of his audacity." His
death is accidental, but, in Conrad's merciful last words, he has,
after his death, the "greatest, the most enviable, the most sinister of
his successes. In that true cry of love and grief that seemed to ring
aloud from Punta Mala to Azuera and away to the bright line of the
horizon, overhung by a big white cloud shining like a mass of solid
silver, the genius of the magnificent Capataz de Caegadores
dominated the dark gulf containing his conquests of treasure and
love."

II

Conrad's first fame was made by his sea-novels, and the sea is never
quite out of any of his books. Who, before or since, could have
evoked this picture of heat, stillness and solitude?
In Typhoon we are cast into the midst of a terrible outrage of the
destructive force of nature:

something formidable and swift, like the sudden smashing of a


vial of wrath. It seemed to explode all round the ship with an
overpowering concussion and a rush of great waters, as if an
immense dam had been blown up to windward. In an instant
the men lost touch of each other. This is the disintegrating
power of a great wind; it isolates one from one's kind. ... The
motion of the ship was extravagant. Her lurches had an
appalling helplessness; she pitched as if taking a header into a
void, and seemed to find a wall to hit every time. ... The seas in
the dark seemed to rush from all sides to keep her back where
she might perish. There was hate in the way she was handled,
and a ferocity in the blows that fell. She was like a living
creature thrown to the rage of a mob! hustled terribly, struck at,
borne up, flung down, leaped upon. ... At last she rose slowly,
staggering, as if she had to lift a mountain with her bows.

There have been many writers about the sea, but only Conrad has
loved it with so profound and yet untrustful a love. His storms have
sublimity, made out of intense attention to detail, often trivial or
ludicrous, but heightened into tragedy by the shifting floor and
changing background on which is represented the vast struggle of
man with the powers of nature. And as he loves the earth only in its
extravagances, so he loves the sea most in storm, where love and
fear mingle. The tropics, the Malay Archipelago, and the sea in a
continual tempest, the ship suffering through a typhoon, or burning
itself out on the waters: these are his scenes, these he cherishes in
his faithful and unquiet memory. How much is memory, how much is
imagination, no one need know or care. They are one; he does not
distinguish between them.
Once, in one of the pages of Lord Jim, Conrad has confessed himself
with perfect frankness. He represents himself receiving a packet of
letters which are to tell him the last news of Lord Jim. He goes to
the window and draws the heavy curtains.

The light of his shaded reading-lamp slept like a sheltered pool,


his footfalls made no sound on the carpet, his wandering days
were over. No more horizons as boundless as hope, no more
twilights within the forests as solemn as temples, in the hot
quest for the Ever-undiscovered Country over the hill, across the
stream, beyond the wave. The hour was striking! No more! No
more!—but the opened packet under the lamp brought back the
sounds, the visions, the very savor of the past—a multitude of
fading faces, a tumult of low voices, dying away upon the
shores of distant seas under a passionate and unconsoling
sunshine. He sighed and sat down to read.

That is the confession of one who, of foreign race, is an alien,


solitary among his memories.

III

Conrad's stories have no plots, and they do not need them. They are
a series of studies in temperaments, deduced from slight incidents;
studies in emotion, with hardly a rag to hold together the one or two
scraps of action, out of which they are woven. A spider hanging by
one leg to his web, or sitting motionless outside it: that is the image
of some of these tales, which are made to terrify, bewilder and grip
you. No plot ever made a thing so vital as Lord Jim, where there is
no plot; merely episodes, explanations, two or three events only
significant for the inner meaning by which they are darkened or
illuminated. I would call this invention, creation; the evasion of what
is needless in the plots of most novels. But Conrad has said, of
course, the right thing, in a parenthesis: "It had that mysterious,
almost miraculous, power of producing striking effects by means
impossible of detection, which is the last word of the highest art."
Conrad conceals his astonishing invention under many disguises.
What has seemed to some to be untidy in construction will be found
to be a mere matter of subtlety, a skilful arresting of the attention, a
diverting of it by a new interest thrust in sideways. Lord Jim is a
model of intelligent disarray.
In the strict sense Conrad is not a novelist: he writes by instinct. And
his art is unlike the art of every other novelist. For instance,
Meredith or Stendhal make great things out of surface material; they
give us life through its accidents, one brilliantly, the other with
scrupulous care. Conrad uses detail as illustrations of his ideas, as
veils of life, not as any essential part of it. The allusion to him is
more real than the fact; and, when he deals with the low or trivial,
with Mr. Verloc's dubious shop in the backstreet, it is always a
symbol.
Conrad, writing in English, does not always think in English. For, in
this man, who is pure Polish, there is a brooding mind, an exalted
soul, a fearless intelligence, a merciful judgment. And he has
voyaged through many seas of the soul, in which he finds that
fascination, the fascination of fear, splendor, and uncertainty, which
the water that surrounds the earth had to give him. And he has
made for himself a style which is personal, unique, naked English,
and which brings into English literature an audacious and profound
English speech.
In his sarcasm Conrad is elemental. He is a fatalist, and might say
with Sidi Ali Ismayem, in the Malay Annals: "It is necessary that
what has been ordained should take place in all creatures." But in
his fatalism there is a furious revolt against all those evils that must
be accepted, those material and mental miseries that will never be
removed. His hatred of rule, measure, progress, civilization is
unbounded. He sits and laughs with an inhuman laughter, outside
the crowd, in a chair of wisdom; and his mockery, persuaded of the
incurable horrors of existence, can achieve monstrosity, both logical
and ghastly.
In the "simple tale" of The Secret Agent, which is a story of horror,
in our London of to-day, the central motive is the same as that of
the other romances: memory as Nemesis. The man comes to his
death because he can not get a visible fear out of his eyes; and the
woman kills him because she can not get a more terrible, more
actual thing, which she has not seen, but which has been thrust into
her brain, out of her eyes. "That particular fiend" drives him into a
cruel blunder and her into a madness, a murder, a suicide, which
combine into one chain, link after link, inevitably.
The blood-thirstiness of Conrad's "simple story" of modern life, a
horror as profound as that of Poe, and manipulated with the same
careful and attentive skill, is no form of cruelty, but of cold
observation. What is common enough among the half-civilized
population of that Malay Peninsula, which forms so much of the
material of the earlier novels, has to be transported, by a choice of
subject and the search for what is horrible in it, when life comes to
be studied in a modern city. The interest is still in the almost less
civilized savagery of the Anarchists; and it is around the problem of
blood-shedding that the whole story revolves. The same lust of
slaughter, brought from Asia to Europe, seems cruder and less
interesting as material. There the atmosphere veiled what the
gaslight of the disreputable shop and its back-parlor do but make
more visible. It is an experiment in realism which comes dangerously
near to being sensational, only just avoids it.
The whole question depends upon whether the material horror
surpasses that horror of the soul which is never absent from it;
whether the dreadful picture of the woman's hand holding the
carving-knife, seen reflected on the ceiling by the husband in the
last conscious moment before death, is more evident to us than the
man's sluggish acquiescence in his crime and the woman's slow
intoxication by memory into a crime more direct and perhaps more
excusable. It seems, while you are reading it, impossible that the
intellect should overcome the pang given to the senses; and yet, on
reflection, there is the same mind seen at work, more ruthlessly,
more despairingly than ever, turning the soul inside out, in the
outwardly "respectable" couple who commit murder, because they
"refrained from going to the bottom of facts and motives." Conrad
has made a horrible, forgivable, admirable work of art out of a bright
tin can, a befouled shovel, and a stained carving knife. He has made
of these three domestic objects the symbols of that destroying
element, "red in tooth and claw," which turns the wheel on which
the world is broken.

MAURICE MAETERLINCK

Often, mostly at night, a wheel of memory seems to turn in my head


like a kaleidoscope, flashing out the pictures and the visions of my
own that I keep there. The same wheel turned in my head when I
was in Dieppe with Charles Conder, and it turned into these verses:
There's a tune burns, bums in my head,
And I hear it beat to the sound of my feet,
For that was the tune we used to walk to
In the days that are over and dead.

Another tune turns under and over.


And it turns in my brain as I think again
Of the days that are dead, and the ways she walks now,
To the self-same tune, with her lover.
I see, for instance, Mallarmé, with his exquisite manner of welcome,
as he opens the door to me on the fourth floor of the Rue de Rome;
I hear Jean Moréas thunder out some verses of his own to a
waitress in a Bouillon Duval, whose name was Celimène, who
pretended to understand them; Stuart Mérill at the Rue Ballier, Henri
de Regnier silent under his eye-glass in one of the rooms of the
Mercerie de France; Maurice Maeterlinck in all the hurry of a
departure, between two portmanteaux. That was, I suppose, one of
the most surprising meetings I ever had; for, as a matter of fact, one
night in Fountain Court, it was in 1894—I was equally surprised
when I opened his Alladine et Palamides which he had sent me with
a dedication. After that time I saw him, during several years, fairly
often in Paris and once in Rome, in 1903, when one performance
was given of his Joyzelle—the most unsatisfactory performance I
ever saw, and of certainly an unsatisfactory play. Nervous as he
always was—he used, for one thing, to keep a loaded revolver
always beside him in his bedroom—he shirked the occasion and
went to Naples. I have never forgotten the afternoon when he read
to me in his house in Paris whole pages of Monna Vanna. After I had
left the house, I said to a certain lady who was with me: "Rhetoric,
nothing but rhetoric! It may be obviously dramatic; but the worst of
it is, all the magic and mystery of his earlier plays had vanished:
there is logic rather than life."
It is very unfortunate for a man to be compared to Shakespeare
even by his enemies, when he is only twenty-seven and has time
before him. That is what has happened to Maurice Maeterlinck. Two
years ago the poet of Serres Chaudes was known to only a small
circle of amateurs of the new; he was known as a young Belgian of
curious talent who had published a small volume of vague poems in
monotone. On the appearance of La Princesse maleine, in the early
part of 1890, Maeterlinck had an unexpected "greatness thrust upon
him" by a flaming article of Octave Mirbeau, the author of that
striking novel Sébastian Roch in the Figaro of August 24th. "Maurice
Maeterlinck," said this uncompromising enthusiast,

"nous a donné l'oeuvre la plus géniale de ce temps, et la plus


extraordinaire et la plus naive aussi, comparable—et oserai-je le
dire?—supérieure en beauté à ce qu'il y a de plus beau dans
Shakespeare.... plus tragique que 'Macbeth,' plus extraordinaire
de pensée que 'Hamlet.'"

In short, there was no Shakespearean merit in which La Princesse


Maleine was lacking, and it followed that the author of La Princesse
Maleine was the Shakespeare of our age—the Belgian Shakespeare.
The merits of Maeterlinck were widely discussed in France and
Belgium, and it was not long before the five-act drama was followed
by two pieces, each in one act, called L'Intruse and Les Aveugles. In
May, 1891, L'Intruse was given by the Théâtre d'Art at the Vaudeville
on the occasion of the benefit of Paul Verlaine and Paul Gauguin.
He is not entirely the initiator of this impressionistic drama; first in
order of talent, he is second in order of time to another Belgian,
Charles van Lerberghe, to whom Les Aveugles is dedicated. It was
Van Lerberghe (in Les Flaireurs, for example) who discovered the
effect which might be obtained on the stage by certain appeals to
the sense of hearing and of sight, newly directed and with new
intentions. But what is crude and even distracting in Les Flaireurs
becomes an exquisite subtlety in L'Intruse. In La Princesse Maleine,
in L'Intruse, in Les Aveugles, in Les Sept Princesses, Maeterlinck has
but one note, that of fear—the "vague spiritual fear" of imaginative
childhood, of excited nerves, of morbid apprehension. In La
Princesse Maleine there is a certain amount of action—action which
is certainly meant to reinvest the terrors of Macbeth and of Lear. In
L'Intruse and Les Aveugles the scene is stationary, the action but
reflected upon the stage, as if from some other plane. In Les Sept
Princesses the action, such as it is, is "such stuff as dreams are
made of," and is literally, in great part, seen through a window. From
first to last it is not the play, but the atmosphere of the play, that is
"the thing." In the creation of this atmosphere Maeterlinck shows his
particular skill; it is here that he communicates to us the nouveau
frisson, here that he does what no one has done before.
La Princesse Maleine, it is said, was written for a theater of
marionettes, and it is, certainly, with the effect of marionettes that
these sudden, exclamatory people come and go. Maleine, Hjalmar,
Uglyane—these are no characters, these are no realizable persons;
they are a mask of shadows, a dance of silhouettes behind the white
sheet of the "Chat Noir," and they have the fantastic charm of these
enigmatical semblances—"luminous, gem-like, ghost-like"—with,
also, their somewhat mechanical eeriness. Maeterlinck has recorded
his intellectual debt to Villiers de l'Isle Adam, but it was not from the
author of Axel that he learned his method. The personages of
Maeterlinck—are only too eloquent, too volubly poetical. In their
mystical aim Villiers and Maeterlinck are at one; in their method
there is all the difference in the world. This is how Sara, in Axel,
speaks:—

Songe! Des coeurs condamnés à ce supplice de pas m'aimer! ne


sont-ils pas assez infortunés d'être d'une telle nature?

But Maleine has nothing more impressive to say than this:—

Mon Dieu! mon Dieu! comme je suis malade! Et je ne sais pas


ce que j'ai;—et personne ne sait ce que le médecin ne sait pas
ce que j'ai; ma nourrice ne sait pas ce que j'ai; Hjalmar ne sait
pas ce que j'ai.

That these repetitions lend themselves to parody is obvious; that


they are sometimes ridiculous is certain; but the principle which
underlies them is at the root of much of the finest Eastern poetry—
notably in the Bible. The charm and the impressiveness of monotony
is one of the secrets of the East; we see it in their literature, in their
dances, we hear it in their music. The desire of the West is after
variety, but as variety is the most tiring of all excesses, we are in the
mood for welcoming an experiment in monotone. And therein lies
the originality, therein also the success of Maeterlinck.
In comparing the author of La Princesse Maleine with Shakespeare,
Mirbeau probably accepted for a moment the traditional
Shakespeare of grotesque horror and violent buffoonery. There is in
Maleine something which might be called Elizabethan—though it is
Elizabethan of the school of Webster and Tourneur rather than of
Shakespeare. But in L'Intruse and Les Aveugles the spiritual terror
and physical apprehension which are common to all Maeterlinck's
work have changed, have become more interior. The art of both
pieces consists in the subtle gradations of terror, the slow, creeping
progress of the nightmare of apprehension. Nothing quite like it has
been done before—not even by Poe, not even by Villiers. A brooding
poet, a mystic, a contemplative spectator of the comedy of death—
that is how Maeterlinck presents himself to us in his work, and the
introduction which he has prefixed to his translation of L'Ornement
des Noces Spirituelles of Ruysbroeck l'Admirable shows how deeply
he has studied the mystical writers of all ages, and how much akin
to theirs is his own temper. Plato and Plotinus, Saint Bernard and
Jacob Boehme, Coleridge and Novalis—he knows them all, and it is
with a sort of reverence that he sets himself to the task of
translating the astonishing Flemish mystic of the thirteenth century,
known till now only by the fragments translated into French by
Ernest Hello from a sixteenth-century Latin version. This translation
and this introduction help to explain the real character of
Maeterlinck's dramatic work—dramatic as to form, by a sort of
accident, but essentially mystical. As a dramatist Maeterlinck has but
one note—that of fear; he has but one method—that of repetition.
This is no equipment for a Shakespeare, and it will probably be some
time before Maeterlinck can recover from the literary damage of so
incredible a misnomer.
In the preface to the first volume of the collected edition, which
should be read with attention by all who are interested in knowing
Maeterlinck's opinion of his own work, we are told:—
Quant aux deux petites pièces... je voudrais qu'il n'y eut aucun
malentendu à leur endroit. Ce n'est pas parce qu'elles sont
postérieures qu'il y faudrait chercher une évolution ou un
nouveau désir. Ce sont, à proprement parler, de petits jeux de
scène, de courts poèmes du genre assez malheureusement
appelé "opéra-comique" destinés à fournir, aux musiciens qui les
avaient demandés, un thème convenable à des développements
lyriques. Ils ne prétendent à rien d'avantage, et l'on se
méprendrait sur mes intentions si l'on y voulait trouver par
surcroit de grandes arrière-pensées morales ou philosophiques.

Maeterlinck may be taken at his word, and, if we take him at his


word, we shall be the less disappointed. The two new plays are
slight; they have neither the subtlety of meaning nor the
strangeness of atmosphere which gives their quality of beauty and
force to Pelléas et Mélisande and to Les Aveugles. Soeur Béatrice is
a dramatic version of the legend which Davidson told effectively in
theBallad of a Nun; Ariane et Barbe-Bleue is a new reading of the
legend of Blue-Beard. Both are written in verse, although printed as
prose. It may be remembered that Maeterlinck once admitted that
La Princesse Maleine was meant to be a kind of verse libre, and that
he had originally intended to print it as verse. As it stands now it is
certainly not verse in any real sense, where—as Soeur Béatrice is
written throughout on the basis of the Alexandrine, although without
rhyme. The mute e is, as in most modern French verse, sometimes
sounded and sometimes not sounded; short lines are frequently
interspersed among the lines of twelve syllables. Here are a few
lines, taken at random, and printed as verse;—
Tu ne me réponds pas? Je n'entends pas ton souffle...
Et tes genoux fléchissent.... Viens, viens,
n'attendons pas
Que l'aurore envieuse tende ses pièges d'or
Par les chemins d'azur qui mènent au bonheur.
That is perfectly regular twelve-syllable verse with the exception of
the second line, where the final ent of fléchissent is slurred. Twelve-
syllable unrhymed verse is almost as disconcerting and unknown in
English as in French, but it has been used, with splendid effect, by
Blake, and it is a metre of infinite possibilities. The metre of Ariane
et Barbe-Bleue (as Maeterlinck has finally decided to call it) is vaguer
and more capricious; some of it is in twelve-syllable verse, some in
irregular verse, and some in what can not be called verse at all.
Take, for instance:—

Il parait qu'on pleurait dans les rues.—Pourquoi est-elle venue?


On m'a dit qu'elle avait son idée. Il n'aura pas celle-ci.

The form in French is not, to our ears, successfully achieved; it


seems to take a hesitating step upon the road which Paul Fort, in his
Ballades Françaises has tramped along so vigorously, but in so
doubtful a direction. Fort has published several volumes, which have
been much praised by many of the younger critics, in which verse is
printed as verse—verse which is sometimes rhymed and sometimes
unrhymed, sometimes regular and sometimes irregular; and along
with this verse there is a great deal of merely rhythmical prose,
which is not more like verse than any page of Salammbo, or À
Rebours, or L'Étui de Nacre. Now it seems to us that this
indiscriminate mingling of prose and verse is for the good neither of
prose nor of verse. It is a breaking down of limits without any
conquest of new country. The mere printing of verse as prose, which
Maeterlinck has favored, seems to us a travesty unworthy of a writer
of beautiful prose or of beautiful verse.
Le Temple Enseveli is by no means equal, as literature or as
philosophy, to Le Trésor des Humbles, or even to La Sagesse et la
Destinée, but it is, like everything which Maeterlinck writes, full of
brooding honesty of thought and of a grave moral beauty of feeling.
It is the work of a thinker who "waits patiently," like a Christian upon
divine grace, upon the secret voices which come to us out of the
deepest places in our nature. He is absolutely open-minded, his trust
and his skepticism are alike an homage to truth. If what he has to
say to us is not always "la sagesse même," it is at least the speech
of one who has sought after wisdom more heedfully than any other
writer of our time.
Le Double Jardin is a collection of essays which form a kind of
postscript to Le Temple Enseveli. They are somewhat less abstract,
perhaps a little more casual, than the essays in that book, and are
concerned with subjects as varied as The Wrath of the Bee, The
Motor-Car, and Old-fashioned Flowers. Maeterlinck has never written
anything in prose more graceful, more homely, and more human
than some of these pages, particularly those on flowers. In The Leaf
of Olive and in Death and the Crown he carries speculation beyond
the limits of our knowledge, and "thinks nobly," not of the soul
alone, but also of the intelligence of man in its conflict with the
deadly, unintelligent oppositions of the natural forces of the world.
Such pages are fortifying, and we can not but be grateful for what is
plausible in their encouragement. But the larger part of the book is
made up of notes by the way, which have all the more charm
because they are not too systematically arranged.
All, it is true, have some link of mutual relation, and proceed from a
common center. It is curious to see this harmonizing instinct at work
in the present arrangement of the essay now called Éloge de l'Épée.
The main part of this essay was published in the Figaro in 1902
under the title La Défense de l'Épée. In the Figaro it began with a
merely topical reference:—

L'autre jour, dans un article charmant, Alfred Capus prévoyait la


fin de l'honneur, du moins de "l'honneur salle d'armes" et des
instruments qui le protègent.

Then followed two paragraphs questioning, a little vaguely,

si nous vivions dans une société qui nous protège suffisamment


pour nous enlever, en toutes circonstances, le droit le plus doux
et le plus cher à l'instinct de l'homme—celui de se faire justice à
soi-même.
In the essay as we now read it the topical reference has
disappeared, and more than three pages are occupied by a
discussion of abstract right, of essential justice, which seems to set,
strangely and unexpectedly, a solid foundation under a structure not
visibly resting on any foundation sufficient for its support. As the
essay now stands it has its place in a system of which it becomes
one more illustration.
Few of the essays in this book will be read with more interest than
that on The Modern Drama. It is a development of the ideas already
suggested by Maeterlinck in two prefaces. In asking where, under
the conditions of modern life, and in the expression of modern ideas,
we can find that background of beauty and of mystery which was
like a natural atmosphere to Sophocles and to Shakespeare, he is
asking, not indeed answering, a question which is being asked just
now by all serious thinkers who are concerned with the present and
the future of the drama. This suggestive essay should be contrasted
and compared with a not less suggestive, but more audaciously
affirmative essay, De l'Évolution du Théâtre, given as a lecture by
André Gide, and reprinted at the beginning of the volume containing
his two latest plays Saul and Le Roi Candaule. Everything that Gide
writes is full of honest, subtle and unusual thought, and this
consideration of the modern drama, though it asks more questions,
not answering them, seems also to answer a few of the questions
asked by Maeterlinck.

II

Le Trésor des Humbles is in some respects the most important, as it


is certainly the most purely beautiful, of Maeterlinck's works. Limiting
himself as he did in his plays to the rendering of certain sensations,
and to the rendering of these in the most disembodied way possible,
he did not permit himself to indulge either in the weight of wisdom
or the adornment of beauty, each of which would have seemed to
him (perhaps wrongly) as an intrusion. Those web-like plays, a very
spider's work of filminess, allowed you to divine behind them one
who was after all a philosopher rather than a playwright. The
philosopher could but be divined, he was never seen. In these
essays he has dropped the disguise of his many masks. Speaking
without intermediary, he speaks more directly, with a more absolute
abandonment of every convention of human reserve, except the
reserve of an extreme fastidiousness in the choice of words simple
enough and sincere enough to convey exactly his meaning, more
spontaneously, it would seem, than any writer since Emerson. From
Emerson he has certainly learned much; he has found, for instance,
the precise form in which to say what he has to say, in little essays,
not, indeed, so disconnected as Emerson's, but with a like care to
say something very definite in every sentence, so that that sentence
might stand by itself, without its context, as something more than a
mere part of a paragraph. But his philosophical system, though it
has its essential links with the great mystical system, which has
developed itself through many manifestations, from Plotinus and
Porphyry downward, is very much his own, and owes little to
anything but his own meditation; and whether his subject is La
Beauté Intérieure or Les Femmes, Les Avertis or Le Tragique
Quotidien, it is with the same wisdom, certainty and beauty that he
speaks. The book might well become the favorite reading of those
persons to whom beauty must come with a certain dogmatism, if it
is to be accepted for what it is. It reveals the inner life, with a
simplicity which would seem the most obvious if it were not the
rarest of qualities. It denies nothing, but it asserts many things, and
it asserts nothing which has not been really seen.
In the preface to the first volume of his Théâtre, Maeterlinck takes
us very simply into his confidence, and explains to us some of his
intentions and some of his methods. He sees in La Princesse Maleine
one quality, and one only: "une certaine harmonie épouvantée et
sombre." The other plays, up to Aglavaine et Sélysette, "présentent
une humanité et des sentiments plus précis, en proie à des forces
aussi inconnues, mais un peu mieux dessinées." These unknown
forces, "au fond desquelles on trouve l'idée du Dieu chrétien, mêlée
à celle de la fatalité antique," are realized, for the most part, under
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookgate.com

You might also like