SlideShare a Scribd company logo
Making Use of JSP 1st Edition Madhushree Ganguli
download
https://ebookname.com/product/making-use-of-jsp-1st-edition-
madhushree-ganguli/
Get Instant Ebook Downloads – Browse at https://ebookname.com
Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...
JSP Practical Guide for Programmers 1st Edition Robert
Brunner
https://ebookname.com/product/jsp-practical-guide-for-
programmers-1st-edition-robert-brunner/
JSTL Practical Guide for JSP Programmers 1st Edition
Sue Spielman
https://ebookname.com/product/jstl-practical-guide-for-jsp-
programmers-1st-edition-sue-spielman/
Technology Transfer in Biotechnology A Global
Perspective 1st Edition Prabuddha Ganguli
https://ebookname.com/product/technology-transfer-in-
biotechnology-a-global-perspective-1st-edition-prabuddha-ganguli/
Race and Ethnicity in Latin America 2nd Edition Peter
Wade
https://ebookname.com/product/race-and-ethnicity-in-latin-
america-2nd-edition-peter-wade/
Goddess Traditions in Tantric Hinduism History Practice
and Doctrine 1st Edition Bjarne Wernicke Olesen
(Editor)
https://ebookname.com/product/goddess-traditions-in-tantric-
hinduism-history-practice-and-doctrine-1st-edition-bjarne-
wernicke-olesen-editor/
Women s Studies A Recommended Bibliography Third
Edition Linda A. Krikos
https://ebookname.com/product/women-s-studies-a-recommended-
bibliography-third-edition-linda-a-krikos/
The Act of Remembering Toward an Understanding of How
We Recall the Past 1st Edition John H. Mace
https://ebookname.com/product/the-act-of-remembering-toward-an-
understanding-of-how-we-recall-the-past-1st-edition-john-h-mace/
Ethical trade a comprehensive guide for companies
Second Edition Ethical Trading Initiative
https://ebookname.com/product/ethical-trade-a-comprehensive-
guide-for-companies-second-edition-ethical-trading-initiative/
A Computational Introduction to Number Theory and
Algebra Victor Shoup
https://ebookname.com/product/a-computational-introduction-to-
number-theory-and-algebra-victor-shoup/
Themes of the American Civil War The War Between the
States Revised Second Edition Susan-Mary Grant
https://ebookname.com/product/themes-of-the-american-civil-war-
the-war-between-the-states-revised-second-edition-susan-mary-
grant/
Making Use of JSP 1st Edition Madhushree Ganguli
Madhushree Ganguli
Making Use of JSP
Wiley Publishing, Inc.
Making Use of JSP 1st Edition Madhushree Ganguli
Making Use of JSP
Making Use of JSP 1st Edition Madhushree Ganguli
Madhushree Ganguli
Making Use of JSP
Wiley Publishing, Inc.
Publisher: Robert Ipsen
Editor: Ben Ryan
Developmental Editor: Kathryn A. Malm
Managing Editor: Angela Smith
New Media Editor: Brian Snapp
Text Design & Composition: John Wiley Production Services
Designations used by companies to distinguish their products are often claimed as trade-
marks. In all instances where John Wiley & Sons, Inc., is aware of a claim, the product names
appear in initial capital or ALL CAPITAL LETTERS. Readers, however, should contact the appro-
priate companies for more complete information regarding trademarks and registration.
This book is printed on acid-free paper. ∞
Copyright © 2002 by Madhushree Ganguli. All rights reserved.
Published by Wiley Publishing, Inc., New York
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 Sections 107 or 108 of the 1976 United States Copy-
right 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,
222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4744. Requests to
the Publisher for permission should be addressed to the Permissions Department, John
Wiley & Sons, Inc., 605 Third Avenue, New York, NY 10158-0012, (212) 850-6011, fax (212)
850-6008, E-Mail: PERMREQ @ WILEY.COM.
This publication is designed to provide accurate and authoritative information in regard to
the subject matter covered. It is sold with the understanding that the publisher is not
engaged in professional services. If professional advice or other expert assistance is required,
the services of a competent professional person should be sought.
Library of Congress Cataloging-in-Publication Data:
ISBN 0-471-21974-6
Wiley also publishes its books in a variety of electronic formats. Some content that appears
in print may not be available in electronic versions. For more information about Wiley prod-
ucts, visit our Web site at www.wiley.com.
Printed in the United States of America.
10 9 8 7 6 5 4 3 2 1
Introduction xv
Scenario xxiii
Chapter 1 Introducing Web Development 1
Getting Started 1
Internet Basics 2
The Two-Tier Architecture 5
The Three-Tier Architecture 6
How the Internet Works 8
The Internet Addressing Scheme 8
The World Wide Web 9
Web Browsers 11
The HTTP Request 14
Summary 16
Chapter 2 Introducing Java Server Pages 17
Getting Started 17
Java Server Pages 19
JSP Life Cycle 20
Comparing JSP with Existing Technologies 22
JSP and Servlets 22
JSP and ASP 23
Setting Up the J2EE Environment 25
Verify the Hardware Configuration of the Computers 25
Identify the Components to Be Installed 26
Install the Java Development Kit 26
Install the Server 27
Set the Environment 27
Test the Server 30
Summary 32
Contents
v
Chapter 3 Servlet Basics 35
Getting Started 35
Introduction to Servlets 38
Working of a Servlet 38
Characteristics of Servlets 39
Java Servlet Architecture 40
Servlet Class Hierarchy 41
Life Cycle of a Servlet 42
Servlets and Other Server-Side Scripting Technologies 44
Sevlets and CGI Scripts 44
Servlets and Active Server Pages (ASP) 44
Creating a Servlet 45
Identify the Mechanism for Accepting and Displaying
the Details 46
Identify the Classes to Be Used 46
Identify the Methods to Be Used 46
Write the Code for the Servlet 46
Compile the Servlet Code 47
Deploy the Servlet 48
Execute the Servlet 53
Summary 55
Chapter 4 Creating a JSP Page 57
Getting Started 57
Components of a JSP Page 58
HTML Tags 59
JSP Tags 59
Generating Static Content by Using JSP 61
Identify the Basic HTML Components of the Code 61
Identify the Basic JSP Components of the Code 61
Formulate the Acknowledgment Statement for the JSP Page 64
Write the Code for the Application 65
Execute the Code 65
View the JSP Page 66
Generating Dynamic Content by Using JSP 67
Identify the Basic JSP Components of the Code 67
Write the Code for the Application 67
Execute the Code 68
View the JSP Page 68
Summary 69
Chapter 5 Using JSP Directives and Action Elements 71
Getting Started 71
JSP Directives 72
vi Contents
Using JSP Directives 73
Identify the Data That Needs to Be Accepted for the
Login Screen 74
Design the User Interface Screen for the Login Page 75
Identify the JSP Tag to Add the Bank’s Name and
Logo to the Login Page 75
Write the HTML Code for the Login Page 82
Add the Tag-Specific Line of Code to the Login Page Code 83
Execute the Code 84
View the JSP Page 84
Standard Actions 86
Using JSP Standard Actions 87
Identify the Mechanism to Be Used 88
Identify the JSP Tag to Add the Content of the Schedule
to the Login Page 98
Add the Tag-Specific Line of Code to the Login Page Code 98
Execute the Code 99
View the JSP Page 99
Change the Date and Time of the Schedule to Verify
It Has Been Updated in the JSP Page 99
Summary 101
Chapter 6 Working with HTML Forms 103
Getting Started 103
HTML Forms 104
Creating an HTML Form 105
Identify the Components for the User Interface 105
Identify the HTML Form Elements for the User Interface 106
Identify the Mechanism for Transfer of Data 124
Write the Code for the HTML Form 125
View the HTML Form 127
Validate the Form Data Values 128
Write the HTML Code to Validate User Input 129
Submit the Form to Validate the Data in the Form 131
Summary 131
Chapter 7 Implicit Objects 133
Getting Started 133
Implicit Objects 134
Using JSP Implicit Objects 135
Identify the Components of the Welcome Page 135
Identify the HTML Form Elements 136
Identify the JSP Elements for Creating the
Personalized Message 137
Contents vii
Write the Code to Display the Personalized Message 146
Execute the Code 148
View The JSP Page 148
Using the JSP out Object 149
Identify the Components of the HTML Page 149
Identify the HTML Form Elements 150
Identify the JSP Elements to Be Included in the
Acknowledgment Page 150
Write the Code for the HTML Form 151
Write the Code for the JSP Page 152
Execute the Code 152
View the JSP Page 153
Summary 154
Chapter 8 Using Scripting Elements 155
Getting Started 156
Scripting Elements 156
Using JSP Scripting Elements 157
Identify the Components of the Page 157
Identify the Elements of the HTML File 158
Identify the Elements of the JSP Page 159
Write the Code for the HTML file 168
Write the Code for the JSP Page 169
Execute the Code 170
View the JSP Page 171
Summary 172
Chapter 9 JSP and JavaBeans 173
Getting Started 173
A Bean Component 174
JavaBeans 175
Handling Changes in the Bean Property 177
Identify the Mechanism to Be Used to Validate
the Change in the Account Type 178
Identify the Classes and Methods to Be Used 178
Write the Code for the Bean 179
Write the Code for the Listener Bean 180
Add the Bean to an Application 181
Compile and Execute the Programs 182
Verify the Execution of the Program 182
A JSP Example Using JavaBeans 186
Identify the Mechanism for Displaying Account Type
Details Based on the User Input 187
Identify the Elements of the User Interface Screen 187
viii Contents
Identify the Tags for the JSP Page 188
Identify the Components of a Bean 194
Write the Code for the HTML Page 194
Write the Code for the JSP Page 195
Write the Code for a Bean 195
Compile the Java File 196
View the JSP Page 197
Summary 198
Chapter 10 Implementing JDBC Connectivity 201
Getting Started 201
Database Management and Connectivity 202
Introduction to SQL 203
Database Connectivity in Java 207
The JDBC Database Access Models 208
Types of JDBC Drivers 210
Accessing a Database from a JSP Page 212
Identify the Elements of the Input Page 216
Identify the Steps for Connecting to the Database 216
Identify the Statements to Create a Table for the
Registration Entries 218
Identify the SQL Query for Inserting Customer Details 221
Write the Code to Create a Table in the Database 222
Write the Code to Insert the Registration Details
in the Table 223
Create a DSN for the Database 224
Execute the Code to Create the Table in the Database 228
Execute the Code to Insert Data in the Table 228
Verify the Data in the Database 230
Summary 233
Chapter 11 Building JDBC Applications 235
Getting Started 235
Creating a JSP Page 236
Identify the Various Files to Be Used for Validating User Input 237
Identify the Elements of the User Interface 237
Identify the Classes and Methods of the Bean Component 240
Identify the Elements of the JSP Page for Referencing
the Bean Component 240
Write the Java Code for the Bean 241
Write the Code for the JSP Page with the Bean Reference 243
Compile the Code for the Bean Component 243
View the JSP Page 244
Connection Pooling in JSP 245
Contents ix
Displaying Records from the Database by Using
Connection Pooling 246
Identify the Elements of the JSP Page 247
Identify the Various Java Files to Be Used for Creating
a Connection Pool 248
Identify the Tags for the JSP Page 257
Write the Java Code for the ConnectionPool Class 257
Write the Java Code for the DriverUtilities Class 261
Write the Java Code for the DatabaseUtilities Class 263
Write the Java Code for the DBResults Class 268
Write the Code for the Servlet Utilities 271
Write the Code for the JSP Page 273
Compile the Java Files 274
View the JSP Page 275
Summary 275
Chapter 12 Handling Errors 277
Getting Started 277
Handling Errors in JSP 278
Creating an Error Page 279
Design the User Interface to Accept Information
from Customers 279
Identify the Structure of an Error Page 280
Identify the Tag to Link an Error Page to a JSP Page 281
Identify the Components of the JSP Page to Calculate
the Returns on Investments 281
Write the Code for the User Interface 283
Write the Code for the JSP Page to Calculate the Returns
on Investments 283
Write the Code to Display the Error Messages 284
View the JSP Page 285
Generating Customized Error Messages 287
Identify the Additional Inclusions in the JSP Page
to Catch Exceptions 288
Identify the Additional Inclusions in the Error Page
to Display Customized Error Messages 289
Write the Code for the JSP Page to Catch Exceptions 289
Write the Code for the Error Page 290
View the JSP Page 291
Summary 292
Chapter 13 JSP Sessions 293
Getting Started 293
The Session Tracking API 294
Using Cookies for Session Tracking 295
x Contents
Identify the Elements of the Home Page 296
Identify the JSP Tags to Be Included in Order to Display
the Personalized Hit Count 298
Write the Code for the JSP Page 302
View the JSP Page 305
Session Tracking by Using Hidden Form Fields 306
Using a Session Object for Session Tracking 308
Identify the HTML Elements of the Page 309
Identify the JSP Tags to Be Included in Order to Display
the Entries for the List 311
Write the Code for the JSP Page 315
View the JSP Page 317
Using URL Rewriting for Session Tracking 318
Identify the HTML Elements of the Page 319
Identify the JSP Tags to Be Included in Order to Display
the Hit Count 320
Write the Code for the JSP Page 323
View the JSP Page 325
Summary 326
Chapter 14 JSP and XML 327
Getting Started 327
Introducing XML 328
XML versus Relational Databases 329
XML versus HTML 329
XML versus SGML 332
Basic Rules to Create XML Documents 332
Document Type Definition 333
XML Namespaces 336
XML Schemas 336
Extensible Stylesheet Language Transformations (XSL/T) 338
Benefits of XML 340
Generating Dynamic Content in the XML Format 341
Identify the Customer Details to Be Included in the
XML Document 342
Identify the Tags to Be Added to the XML Document 342
Identify the JSP Tag to Be Added to the Document 343
Identify the Java Code to Be Added to the Document 343
Write the Code for the XML Document 344
Write the Code for the JSP Page 345
View the JSP Page 346
APIs to Access XML Data 347
Document Object Model 349
Simple API for XML 350
Contents xi
Consuming XML Data 351
Identify Interfaces, Classes, and Methods 352
Write the Code to Implement Handlers 352
Test the Code 355
Use the Parser Bean from a JSP Page 356
View the JSP Page 357
Summary 358
Chapter 15 Developing Custom Tags 359
Getting Started 359
Custom Tags 360
Need for XML 361
Advantages of Tag Libraries 363
Structure of a Custom Tag 363
Components of a Tag Library 364
The Tag Handler Class 364
The Tag Library Descriptor File 365
The JSP file 365
Developing Simple Tags 366
Identify the Components of the Tag Library 367
Identify the Structure of the Tag Handler Class 367
Identify the Structure of the TLD File 370
Identify the Additional Inclusions in the JSP File 372
Write the Code for the Tag Handler Class 373
Write the Code for the TLD File 373
Write the Code for the JSP File 374
Compile the Tag Handler Class 375
Deploy the Tag Library 375
View the JSP Page 377
Developing a Tag for Database Interaction 386
Identify the Components of the Tag Library 387
Identify the Structure of the Tag Handler Class 387
Identify the Structure of the TLD File 387
Identify the Additional Inclusions in the JSP File 388
Write the Code for the Tag Handler Class 388
Write the Code for the TLD File 390
Write the Code for the JSP File 390
Compile the Tag Handler Class 391
Deploy the Tag Library 391
View the JSP Page 391
Summary 392
xii Contents
Chapter 16 JavaMail 395
Getting Started 395
Introduction to the JavaMail API 396
Using JavaMail in JSP 397
Identify the Elements of the HTML Page to Accept
the Details of the Mail 398
Identify the Elements of the JSP Page to Add the JavaMail
Functionality to the Application 399
Write the Code for the HTML Page 405
Write the Code for the JSP Page 406
View the JSP Page 407
Summary 409
Index 411
Contents xiii
Making Use of JSP 1st Edition Madhushree Ganguli
The world seems to shrink each day, thanks to the ever-increasing power of the Inter-
net. With the growth and popularity of the Internet, even distant areas across the globe
seem closer today. It is indeed the era of fast communication and information exchange.
To retain a commanding position in this changing world, organizations need to prepare
themselves for the rapid development of Web-based applications that are platform-
independent. As a result, organizations need to identify the tools required to emerge as
a formidable force in the competitive world of Web-based applications. Java Server
Pages, or JSP, a Sun Microsystems product, is one tool that is fast catching up as a pre-
ferred technology for creating Web-based applications.
JSP is based on the Java technology and is an extension of the Java Servlet technology.
As a result, platform independence and extensibility of servlets are easily incorporated
in JSP. In addition, using the Java server-side modules, JSP can fit effortlessly into the
framework of a Web server with minimal overhead, maintenance, and support. The
use of XML-like tags and Java-like syntax in JSP facilitate building Web-based applica-
tions with speed and ease as never before.
The power, extensibility, and portability of JSP are well described by the following
statements from Sun Microsystems:
The JSP specification is the product of industry-wide collaboration with industry leaders
in the enterprise software and tools market, led by Sun Microsystems. Sun has made the
JSP specification freely available to the development community with the goal that every
Web server and application server will support the JSP interface.
Future Direction
By working with a consortium of industry leaders, Sun has ensured that the JSP specifica-
tions remain open and portable. Over time, tool vendors and others will extend the func-
tionality of the platform by providing customized tag libraries for specialized functions.
It is beyond doubt that JSP will rule the market in the future and become one of the
most powerful languages for developing Web applications. The use of customized tags
Introduction
xv
and libraries is gaining wide acceptance in the industry as a flexible mechanism that
allows segregation of the work profiles of the page author and the programmer.
Along with conceptual information, this book will also provide extensive practical
exercises for the reader to gain valuable real-life exposure in creating different types of
applications. The aim of this book is to make learning an enjoyable and energizing
process.
Overview of JavaServer Pages
Two friends, Gwen and Griffith, decide to enroll themselves in a short course during
the fall break. While Gwen’s choice is interior decoration, Griffith chooses a more pro-
fessional course in secretarial practice. Both friends, being computer savvy, search the
Internet and come up with the same site advertising their choices of short courses. As
an afterthought, both Gwen and Griffith marveled that although their choice of
courses was different, the same site displayed a list of details for the two completely
different courses. How was the display of the courses linked and changed according to
the search criteria? What actually ensued was a request-response cycle that displayed
the result pertaining to the individual query. In other words, the Web application for
the site received the requests and returned dynamic content in the form of the course
details. In the world of the Internet, dynamism is part and parcel of Web applications.
Technologies such as Hypertext Pre Processor (PHP), Active Server Pages (ASP), and
Java Server Pages (JSP) are used to create dynamic Web applications.
This book will help you understand the JSP technology that can be used to create
applications to generate dynamic content. Java Server Pages allows Web developers
and designers to develop easily maintainable, information-rich, dynamic Web pages.
Java Server Pages separates the user interface from content generation. This enables
designers to change the layout of a Web page without altering the underlying dynamic
content. As a result, the workload can be clearly separated into two categories, the
graphical content created by a designer or a page author and the dynamic content cre-
ated by the developer or the programmer. As a result, in simple words, JSP provides a
simplified, faster way to create dynamic Web content.
History of JSP
Sun Microsystems was founded in 1982. Ever since its inception, Sun Microsystems
has maintained a singular vision of “The Network Is The Computer.” This vision has
helped Sun Microsystems remain as one of the leading providers of industrial-strength
hardware, software, and services to aid companies across the world. The company has
a global presence in more than 170 countries with gross annual revenue crossing the
$17 billion mark.
A significant year in the history of Sun Microsystems was 1995. This was the year
when Sun received ISO 9001 certification for quality in all major country service orga-
nizations and ISO 9002 certification for all worldwide manufacturing operations. In
the same year, the company unleashed Java technology, which was the first universal
software platform designed for the Internet and corporate intranets. Java technology
xvi Introduction
enabled developers to write applications once and run them on computers anywhere
without any modifications. If we flip back the pages of the history of Java, we’ll realize
that the introduction of Java was more of an accident. In fact, you’ll be surprised to
know that Java was originally developed not for computers but for home appliances
such as ovens, toasters, and refrigerators. The accident, though, has proved to be a
boon in disguise—with the popularity of the Internet neither Sun nor Java has had to
look back. Java has worked hard to be accepted and recognized as a favorite language
for developing Web applications.
JSP is a part of the Java family that shares the key characteristics of the Java technol-
ogy: “Write Once, Run Anywhere.” It is a core component of the Java 2 Enterprise Edi-
tion. JSP has inherited most of the features and benefits of both Java and Servlet
technology and is fast gaining acceptance as a standard tool for building dynamic
Web sites.
Features of JSP
JSP provides an attractive alternative to other dynamic scripting languages by offering
the following features:
Platform independence. The use of JSP adds versatility to a Web application by
enabling its execution on any computer.
Enhanced performance. The compilation process in JSP produces faster results
or output.
Separation of logic from display. The use of JSP permits the HTML-specific
static content and a mixture of HTML, Java, and JSP-specific dynamic content
to be placed in separate files.
Ease of administration. The use of JSP eliminates the need for high-level techni-
cal expertise, thereby helping Web developers, designers, content creators, and
content managers to work together and develop Java-based applications in less
time and with less effort.
Ease of use. All JSP applications run on major Web servers and operating sys-
tems, including Microsoft IIS, Netscape Enterprise Server, iPlanet Web Server,
and Apache Web Server. These applications are also available on Windows NT,
Windows 2000, and Solaris 7.
Users of the Product/Technology
By moving Web development into the twenty-first century, Java Server Pages technol-
ogy enables faster product delivery time. Here are a few examples of enterprises that
are using the Java Server Pages framework to deliver break-away business strategies
for both themselves and their customers:
■
■ Knight Ridder
■
■ Delta Airlines
Introduction xvii
■
■ Waterstone Consulting
■
■ Axtive Software Corporation
■
■ MetaMarkets.com, Inc.
■
■ Cambridge Interactive
■
■ NMG New Media Group
■
■ Epicentric, Inc.
■
■ PostalWorks LLC
■
■ Flashline.com, Inc.
■
■ TheWorksUSA.com
■
■ Klicman Incorporated
■
■ TouchNet Information Systems, Inc.
■
■ Linnebank IT
■
■ Tradiant
Competing Products across Platforms
Competing products include Active Server Pages (ASP), Hypertext Pre Processor
(PKP), and JavaScript.
JSP versus ASP. ASP is the immediate competing technology from Microsoft.
The dynamic content of JSP is written in Java, in contrast to that of ASP, which is
written using an ASP-specific language, such as VBScript. As a result, complex
applications can use the power of Java to reuse and embed Java components in
JSP applications. Second, JSP is portable to other operating systems and servers
in contrast to the allegiance of ASP to Windows NT/2000 and IIS.
JSP versus PHP. PHP is similar to ASP and JSP to a certain extent. PHP is a free,
open-source, HTML-embedded, server-side scripting language. With basic
HTML knowledge, however, a VBScript programmer can write ASP applica-
tions and a Java programmer can create JSP applications, whereas PHP requires
learning an entirely new language. Second, by virtue of the power of Java, JSP
has access to an extensive API for networking, database access, and object
distribution.
JSP versus JavaScript. JavaScript is a programming language that is totally
different from the server-side HTML and Java-based JSP technology. JavaScript
is a client-side programming language used to build parts of HTML Web pages
while the browser loads a document. As a result, the pages generated in
JavaScript create dynamic content that is solely based on the client environment.
JSP applications, by virtue of its being a server-side scripting language, use
mechanisms such as hidden fields, session objects, cookies, and URL rewriting
to access all request data transmitted during a request-response cycle. Equipped
with only cookies as aids to provide request data, the client-side JavaScript
xviii Introduction
routines are unable to access the HTTP request data. Although JavaScript can
be used on servers as a scripting language for IIS, JSP backed by the reliability,
flexibility, and portability of Java is a more powerful technology by far.
How This Book Is Organized
This book differs from the traditional content-based approach and uses the problem-
based approach to deliver the concepts of JSP. Problems used in the book are presented
against the backdrop of real-life scenarios. The problem is followed by a task list that
helps to solve the given problem, in the process explaining the concepts and their
implementation. This practical approach will help readers understand the real-life
application of the language and its use in various scenarios. Moreover, to provide an
appropriate learning experience, the concepts will be supported adequately by case
studies that provide a frame of reference for the reader.
Chapter 1 is a guide to the basics of the Internet and discusses the World Wide Web
environment, browser and server interactions, and the HTTP request-response cycle.
Chapter 2 is a getting-started guide that begins with a brief introduction to JSP. This
is followed by a discussion on the JSP life cycle and concludes with the steps used for
installing and setting up the environment to execute JSP applications.
Chapter 3 attempts to highlight the advantages incorporated in JSP as an extension
of Java Servlet technology. The chapter begins with a discussion of the JavaServlet
architecture and life cycle. The chapter concludes with an example of a simple servlet
that is used to count the number of hits for a particular page.
Chapter 4 introduces concepts related to creating a JSP application. It discusses
the various components of a JSP page by using the simple “Hello World” example. The
difference between static and dynamic content is also discussed using appropriate
examples.
Chapter 6 delves into the all-important concept of HTML forms. All user-specific
input is transferred to the server by using various controls of the HTML page. The
chapter begins with an introduction to HTML forms, followed by a discussion of the
various types of HTML controls that can be added to a form. Next, the mechanisms of
retrieval and transfer of form values in JSP are discussed using a simple example. The
chapter concludes with a JavaScript-aided client-side validation for ensuring user
input in a form control.
Chapters 6, 7, and 8 discuss the different JSP-specific components one by one. Chap-
ter 5 discusses implicit objects, including such implicit objects as request, response, ses-
sion, application, and config. This is followed by a brief discussion of the importance
of the scope of implicit objects.
Chapter 7 discusses two JSP components, directives and action elements. The chap-
ter begins with the types and uses of the page, include, and taglib directives. Next, the
various JSP standard actions are discussed with suitable examples. In the concluding
section of the chapter, examples are used to show the difference in the usage of the
include directive and the include standard action.
Introduction xix
Chapter 8 introduces the scripting elements of JSP that are primarily used to gener-
ate the dynamic content. It discusses the use of the three types of scripting elements:
scriplets, expressions, and declarations.
Chapter 9 explains concepts relating to reusing Java bean components in a JSP page.
The chapter begins with an introduction to JavaBeans, followed by a discussion on
using JavaBeans in JSP. To aid a better understanding of using a bean component in a
JSP page, the chapter concludes with an example that uses a Java bean instead of a
direct use of JSP components to display dynamic content.
Chapter 10 moves on to discussing activities on the server side. This chapter assumes
that the reader has a basic knowledge of databases, data storage in databases, RDBMS
concepts, and their implementation. The chapter begins with a discussion of concepts
pertaining to JDBC basics that include types of JDBC drivers, the various application
architecture, and database access models. Next, the chapter explains the processes of
accessing and manipulating a database by using SQL commands. Finally, a JSP appli-
cation is used as a backdrop to implement database connectivity and discuss concepts
such as connecting to a database, creating a table in a database, and inserting records
in a database.
Chapter 11 combines the concepts of reusing bean components to implement data-
base interactions in JSP applications. The chapter begins with an example of a login
bean that is used to validate and authenticate a user. Next, the concept of connection
pooling is discussed to highlight the importance of economizing the use of Web
resources during a database interaction. The chapter then discusses the various classes
and methods required to create a connection pool in a JSP application.
Chapter 12 delves into handling errors in JSP. The chapter begins with a discussion
of error handling and the implementation of exception handling in JSP. Next, the trans-
lation and request time errors are discussed with examples.
Chapter 13 introduces another important concept of session tracking. The chapter
begins by differentiating between a stateful and stateless session and the importance of
the availability of session-related information in applications. It then discusses the
methods of using cookies, hidden fields, session-tracking APIs, and URL rewriting for
session tracking.
Chapter 14 further discusses the advanced Web programming concepts of using
Simplified API for XML (SAX) and Extensible Markup Language (XML) in JSP appli-
cations. To start with, this chapter discusses the benefits of using XML. This is followed
by a discussion of the SAX API and the use of various classes and methods of the SAX
API to parse the contents of an XML document in JSP.
Chapter 15 delves into developing the relatively new concept of custom tags. This
chapter discusses the need of custom tags in JSP to encapsulate recurring code snip-
pets. The chapter uses examples to discuss in detail the various formats that can be
adopted to add both simple and complex tags in a JSP application. In addition, the
chapter also includes an example that uses a custom tag to initiate a database interac-
tion for retrieving and displaying a particular record from the database.
Chapter 16, the final chapter, is a brief introduction to JavaMail and the importance
of mailing services in our lives today. The chapter wraps up with an example that cre-
ates an application for sending a message by using the class and method declarations
of the JavaMail API.
xx Introduction
Who Should Read This Book
This book is a guide for readers with basic familiarity with HTML and the Java lan-
guage. In this book the content will be covered using lucid examples, sample codes,
and the appropriate use of visuals and demonstrations. The concepts will be supported
adequately by case studies that will be formulated in such a way that they provide a
frame of reference for the reader. Problems will be presented to the reader against the
backdrop of real-life scenarios. The practical approach will help readers to understand
the real-life application of the language and the use of JSP in various scenarios. In a
nutshell, this book will provide a starting point for working with and creating applica-
tions in JSP.
This book is intended for programmers interested in developing dynamic Web sites
by using JSP. The target audience for this book would include the following:
■
■ Web application developers
■
■ Technical support professionals
■
■ Web site administrators
Novice developers of Web applications can use relevant real-world-oriented scenar-
ios and exercises for the concepts covered as a guide to learn the basics of writing Java
Server Pages.
Tools You Will Need
For performing the tasks in this book, you will need a Pentium or faster computer with
a minimum 32MB RAM (64MB RAM recommended).
You will also need the following software:
Operating system: Windows NT 4.0 with Service Pack 6.0.
RDBMS: SQL 7.0.
Text Editors: Notepad or Edit Plus, for example.
Software: Java Development Kit (v 1.3).
Software: Java 2 SDK, Enterprise Edition (v 1.2.1).
What’s on the Web Site
The following will be available on the site www.wiley.com/compbooks/makinguse:
■
■ Java Development Kit (v 1.3)
■
■ Java 2 SDK, Enterprise Edition (v 1.2.1)
■
■ All the code snippets used in the book
Introduction xxi
Making Use of JSP 1st Edition Madhushree Ganguli
Exploring the Variety of Random
Documents with Different Content
vessels could be distinctly seen; and mingled with the myriad noises
from the shore was now the crackle of the flames, and the hiss of
burning spars and rigging as they fell into the water.
The gallivats had separated into two groups; either they had
been cut apart, or, more probably, the lashings had been burnt
through. Around one of the groups Desmond saw a number of small
boats. They appeared to be trying to cut out the middle of the three
gallivats, which seemed to be as yet uninjured, while the vessels on
either side were in full blaze. Owing to the intense heat the men's
task was a difficult and dangerous one, and Desmond had good
hope that they would not succeed until the gallivat was too much
damaged to be of use for pursuit. He wondered, indeed, at the
attempt being made at all; for it kept all the available boats engaged
when they might have dashed upon the grab in tow and made short
work of it. The true explanation of their blunder did not at the
moment occur to Desmond. The fact was that the men trying so
earnestly to save the gallivat knew nothing of what had happened to
the grab. They were aware that a gallivat had been cut loose and
was standing out to sea; but the glare of the fire blinded them to all
that was happening beyond a narrow circle, and as yet they had had
no information from shore of what was actually occurring. When
they did learn that two vessels were on their way to the sea, they
would no doubt set out to recapture the fugitives instead of wasting
their efforts in a futile attempt to save the unsavable.
Desmond was still speculating on the point when another shot
from the fort aroused him to the imminent danger. The dark shapes
of the two vessels must now certainly be visible from the walls. The
shot flew wide. Although the grab was well within range it was
doubtless difficult to take aim, the distance being deceptive and the
sights useless in the dark. But this shot was followed at intervals of a
few seconds by another and another; it was clear that the fugitives
were running the gauntlet of the whole armament on this side of the
fort. The guns were being fired as fast as they could be loaded; the
gunners were becoming accustomed to the darkness, and when
Desmond heard the shots plumping into the water, nearer to him, it
seemed, every time, he could not but recognize that success or
failure hung upon a hair.
Crash! A round shot struck the grab within a few feet of the
wheel. A shower of splinters flew in all directions. Desmond felt a
stinging blow on the forehead; he put up his hand; when he took it
away it was wet. He could not leave the wheel to see what damage
had been done to the ship, still less to examine his own injury. He
was alone on board. Every other man was straining at his oar in the
gallivat. He felt the blood trickling down his face; from time to time
he wiped it away with the loose end of his dhoti. Then he forgot his
wound, for two more shots within a few seconds of each other
struck the grab forward. Clearly the gunners were aiming at his
vessel, which, being larger than the gallivat, and higher in the water,
presented an easier mark. Where had she been hit? If below the
waterline, before many minutes were past she would be sinking
under him. Yet he could do nothing. He dared not order the men in
the gallivat to cease rowing; he dared not leave the helm of the
grab; he could but wait and hold his post. It would not be long
before he knew whether the vessel had been seriously hit: if it was
so, then would be the time to cast off the tow-rope.
The gallivat, at any rate, appeared not to have suffered.
Desmond was beginning to think he was out of the wood when he
heard a crash in front, followed by a still more ominous sound. The
motion of the gallivat at once ceased, and, the grab slowly creeping
up to her, Desmond had to put his helm hard up to avoid a collision.
He could hear the Gujarati raging and storming on deck, and cries as
of men in pain; then, as the grab came abreast of the smaller vessel,
he became aware of what had happened. The mainmast of the
gallivat had been struck by a shot and had gone by the board.
Desmond hailed the Gujarati and told him to get three or four
men to cut away the wreckage.
"Keep an eye on the prisoners," he added, feeling that this was
perhaps the most serious element in a serious situation; for with
round shot flying about the vessel it might well have seemed to the
unhappy men on the rowing benches that mutiny was the lesser of
two risks. But the rowers were cowed by the presence of the two
Biluchis armed with their terrible knives, and they crowded in dumb
helplessness while the tangled rigging was cut away.
"Is any one hurt?" asked Desmond.
"One of the rowers has a broken arm, sahib," replied Shaik
Abdullah.
"And I have a contusion of the nose," said the Babu
lugubriously.
It was impossible to do anything for the sufferers at the
moment. It was still touch-and-go with the whole party. The shots
from the fort were now beginning to fall short, but, for all Desmond
knew, boats might have been launched in pursuit, and if he was
overtaken it meant lingering torture and a fearful death. He was in a
fever of impatience until at length, the tangled shrouds having been
cut away, the rowing was resumed and the two vessels began again
to creep slowly seaward.
Gradually they drew out of range of the guns. Steering straight
out to sea, Desmond had a clear view of the whole of the harbour
and a long stretch of the river. The scene was brightly lit up, and he
saw that two of the gallivats had been towed away from the burning
vessels, from which the flames were now shooting high into the air.
But even on the two that had been cut loose there were spurts of
flame; and Desmond hoped that they had sustained enough damage
to make them unseaworthy.
Suddenly there were two loud explosions, in quick succession. A
column of fire rose towards the sky from each of the gallivats that
were blazing most brightly. The fire had at length reached the
ammunition. The red sparks sprang upwards like a fountain, casting
a ruddy glow for many yards around; then they fell back into the
sea, and all was darkness, except for the lesser lights from the
burning vessels whose magazines had as yet escaped. The
explosions could hardly have occurred at a more opportune moment,
for the darkness was now all the more intense, and favoured the
fugitives.
There was a brisk breeze from the south-west outside the
harbour, and when the two vessels lost the shelter of the headland
they crept along even more slowly than before. Desmond had learnt
enough of seamanship on board the Good Intent to know that he
must have sea-room before he cast off the gallivat and made sail
northwards; otherwise he would inevitably be driven on shore. It
was this fact that had prompted his operations in the harbour. He
knew that the grabs could not put to sea unless they were towed,
and the gallivats being rendered useless, towing was impossible.
The sea was choppy, and the rowers had much ado to control
the sweeps. Only their dread of the Biluchis' knives kept them at
their work. But the progress, though slow, was steady; gradually the
glow in the sky behind the headland grew dimmer; though it was as
yet impossible to judge with certainty how much offing had been
made, Desmond, resolving to give away no chances, and being
unacquainted with the trend of the coast, kept the rowers at work,
with short intervals of rest, until dawn. By this means he hoped to
avoid all risk of being driven on a lee shore, and to throw Angria off
the scent; for it would naturally be supposed that the fugitives would
head at once for Bombay, and pursuit, if attempted, would be made
in that direction.
When day broke over the hills, Desmond guessed that the coast
must be now five miles off. As far as he could see, it ran north by
east. He had now plenty of sea-room; there was no pursuer in sight;
the wind was in his favour, and if it held, no vessel in Angria's
harbour could now catch him. He called to the Gujarati, who shouted
an order to the Biluchis; the worn-out men on the benches ceased
rowing, except four, who pulled a few strokes every now and again
to prevent the two vessels from colliding. Desmond had thought at
first of stopping the rowing altogether and running the grab
alongside the gallivat; but that course, while safe enough in the still
water of the harbour, would have its dangers in the open sea. So,
lashing the helm of the grab, he dropped into a small boat which
had been bumping throughout the night against the vessel's side,
and in a few minutes was on board the gallivat.
He first inquired after the men who had been wounded in the
night. One had a broken arm, which no one on board knew how to
set. The Babu had certainly a much discoloured nose, the contusion
having been caused no doubt by a splinter of wood thrown up by
the shot. Two or three of the rowers had slight bruises and
abrasions, but none had been killed and none dangerously hurt.
Then Desmond had a short and earnest talk with the Gujarati,
who alone of the men had sufficient seamanship to make him of any
value in deciding upon the next move.
"What is to be done with the gallivat?" asked Desmond.
"Scuttle her, sahib, and hoist sail on the grab."
"But the rowers?"
"Fasten them to the benches and let them drown. They could
not help our enemies then, and it would make up for what you and I
and all of us have suffered in Gheria."
"No, I can't do that," said Desmond.
"It must be as I say, sahib. There is nothing else to do. We have
killed no one yet, except the sentinel on the parapet; I did that
neatly, the sahib will agree; I would have a life for every lash of the
whip upon my back."
"No," said Desmond decisively, "I will not drown the men. We
will take on board the grab three or four, who must be sailors; let us
ask who will volunteer. We will promise them good pay; we haven't
any money, to be sure, but the grab can be sold when we reach
Bombay, and though we stole her I think everybody would admit
that she is our lawful prize. I should think they'll be ready enough to
volunteer, for they won't care to return to Gheria and face Angria's
rage. At the same time we can't take more than three or four,
because in the daylight they can now see how few we are, and they
might take a fancy to recapture the grab. What do you think of that
plan?"
The Gujarati sullenly assented. He did not understand mercy to
an enemy.
"There is no need to pay them, sahib," he said. "You can
promise pay; a promise is enough."
Desmond was unwilling to start an argument and said nothing.
Once in Bombay he could ensure that any pledges given would be
strictly kept.
As he expected, there was no difficulty in obtaining volunteers.
Twice the number required offered their services. They had not
found their work with the Pirate so easy and so well rewarded as to
have any great objection to a change of masters. Moreover, they no
doubt feared the reception they would get from Angria if they
returned. And it appeared afterwards that during the night the
Biluchis had recounted many fabulous incidents all tending to show
that the sahib was a very important as well as a very ingenious
Firangi, so that this reputation, coupled with an offer of good pay,
overcame any scruples the men might retain.
Among those who volunteered and whose services were
accepted was the serang of Angria's gallivat. Unknown to Desmond,
while he was holding this conversation with the Gujarati, the serang,
crouching in apparent apathy on his bench, had really strained his
ears to catch what was being said. He, with the three other men
selected, was released from his bonds, and ordered to lower the
long boat of the gallivat and stow in it all the ammunition for the
guns that was to be found in the ship's magazine. This was then
taken on board the grab, and Desmond ordered one of the
Mysoreans to load the grab's stern chaser, telling the Marathas
whom he intended to leave on the gallivat that, at the first sign of
any attempt to pursue, their vessel would be sunk.
Then in two parties the fugitives went on board the grab.
Desmond was the last to leave the gallivat, releasing one of the
captive rowers, who in his turn could release the rest.
As soon as Desmond stepped on board the grab, the hawser
connecting the two vessels was cast off, the mainsail was run up,
and the grab, sailing large, stood up the coast. Fuzl Khan, swarming
up to the mast-head, reported two or three sail far behind,
apparently at the mouth of Gheria harbour. But Desmond, knowing
that if they were in pursuit they had a long beat to windward before
them, felt no anxiety on that score. Besides, the grab he was on had
been selected precisely because it was the fastest vessel in Angria's
fleet.
Having got fairly under way, he felt that he had leisure to
inspect the damage done to the grab by the shots from the fort
which had given him so much concern in the darkness. That she had
suffered no serious injury was clear from the ease with which she
answered the helm and the rapidity of her sailing. He found that a
hole or two had been made in the forepart of the deck, and a couple
of yards of the bulwarks carried away. There was nothing to cause
alarm or to demand instant repair.
It was a bright cool morning, and Desmond, after the
excitements and the strain of the last few days, felt an extraordinary
lightness of spirit as the vessel cut through the water. For the first
time in his life he knew the meaning of the word freedom; none but
a man who has suffered captivity or duress can know such joy as
now filled his soul. The long stress of his menial life on board the
Good Intent, the weary months of toil, difficulty and danger as
Angria's prisoner, were past; and it was with whole-hearted
joyousness he realized that he was now on his way to Bombay,
whence he might proceed to Madras, and Clive--Clive, the hero who
was as a fixed star in his mental firmament.
The gallivat, lying all but motionless on the water, a forlorn
object with the jagged stump of her mainmast, grew smaller and
smaller in the distance, and was soon hull down. Desmond, turning
away from a last look in her direction, awoke from his reverie to the
consciousness that he was ravenously hungry.
CHAPTER THE FIFTEENTH
In which our hero weathers a storm; and prepares for
squalls.
Hungry as he was, however, Desmond would not eat while he was,
so to speak, still in touch with Gheria. He ran up the sail on the
mizzen, and the grab was soon cutting her way through the water at
a spanking rate. He had closely studied the chart on board the Good
Intent when that vessel was approaching the Indian coast--not with
any fixed purpose, but in the curiosity which invested all things
Indian with interest for him. From his recollection he believed that
Gheria was somewhat more than a hundred miles from Bombay. If
the grab continued to make such good sailing, she might hope to
cover this distance by midnight. But she could hardly run into
harbour until the following day. There was of course no chart, not
even a compass, on board; the only apparatus he possessed was a
water-clock; naturally he could not venture far out to sea, but
neither dared he hug the shore too closely. He knew not what reefs
there might be lying in wait for his untaught keel. Besides, he might
be sighted from one or other of the coast strongholds still remaining
in Angria's hands, and it was not impossible that swift messengers
had already been sent along the shore from Gheria, prescribing a
keen look-out and the chase of any solitary grab making northward.
But if he kept too far out he might run past Bombay, though when
he mentioned this to his fellow-fugitives he was assured by the
Biluchis and Fuzl Khan that they would unfailingly recognize the
landmarks, having more than once in the course of their trading and
pirate voyages touched at that port.
On the whole he thought it best to keep the largest possible
offing that would still leave the coast within sight. Putting the helm
down he ran out some eight or ten miles, until the coast was visible
only from the mast-head as a purple line on the horizon, with
occasional glimpses of high ghats[#] behind.
[#] Mountains.
Meanwhile the Gujarati and some of the others had breakfasted
from their bundles. Leaving the former in charge of the wheel,
Desmond took his well-earned meal of rice and chapatis, stale, but
sweet with the sweetness of freedom.
In his ignorance of the coast he felt that he must not venture to
run into Bombay in the darkness, and resolved to heave-to during
the night. At the dawn he could creep in towards the shore without
anxiety, for there was little chance of falling in with hostile vessels in
the immediate neighbourhood of Bombay. Knowing that a
considerable British fleet lay there, the Pirate would not allow his
vessels to cruise far from his own strongholds. But as there was a
prospect of spending at least one night at sea, it was necessary to
establish some system of watches. The task of steering had to be
shared between Desmond and Fuzl Khan; and the majority of the
men being wholly inexperienced, it was not safe to leave fewer than
six of them on duty at a time. The only danger likely to arise was
from the weather. So far it was good; the sea was calm, the sky was
clear; but Desmond was enough of a seaman to know that, being
near the coast, the grab might at any moment, almost without
warning, be struck by a squall. He had to consider how best to
divide up his crew.
Including himself there were eleven men on board. Four of
them were strangers of whom he knew nothing; the six who had
escaped with him were known only as fellow-prisoners.
To minimize any risk, he divided the crew into three watches.
One consisted of the Babu, the serang, and one of the Marathas
from the gallivat. Each of the others comprised a Mysorean, a
Biluchi, and a Maratha. Thus the strangers were separated as much
as possible, and the number of Marathas on duty was never in
excess of the number of fugitives; the steersman, Desmond or the
Gujarati as the case might be, turned the balance.
The watch was set by means of the water-clock found in the
cabin. Desmond arranged that he and Fuzl Khan should take
alternate periods of eight hours on and four off. The two matchlocks
taken from the sentinels of the fort and brought on board were
loaded and placed on deck near the wheel. None of the crew were
armed save the Biluchis, who retained their knives.
Towards midday the wind dropped almost to a dead calm. This
was disappointing, for Desmond suspected that he was still within
the area of Angria's piratical operations--if not from Gheria, at any
rate from some of the more northerly strongholds not yet captured
by the East India Company or the Peshwa. But he had a good offing:
scanning the horizon all around he failed to sight a single sail; and
he hoped that the breeze would freshen as suddenly as it had
dropped.
Now that excitement and suspense were over, and there was
nothing that called for activity, Desmond felt the natural reaction
from the strain he had undergone. By midday he was so tired and
sleepy that he found himself beginning to doze at the wheel. The
Gujarati had been sleeping for some hours, and as the vessel now
required scarcely any attention, Desmond thought it a good
opportunity for snatching a rest. Calling to Fuzl Khan to take his
place, and bidding him keep the vessel's head, as far as he could,
due north, he went below. About six bells, as time would have been
reckoned on the Good Intent, he was wakened by the Babu, with a
message from the Gujarati desiring him to come on deck.
"Is anything wrong, Babu?" he asked, springing up.
"Not so far as I am aware, sahib. Only it is much hotter since I
began my watch."
Desmond had hardly stepped on deck before he understood the
reason of the summons. Overhead all was clear; but towards the
land a dense bank of black cloud was rising, and approaching the
vessel with great rapidity. It was as though some vast blanket were
being thrown seawards. The air was oppressively hot, and the sea
lay like lead. Desmond knew the signs; the Gujarati knew them too;
and they set to work with a will to meet the storm.
Fortunately Desmond, recognizing the unhandiness of his crew,
had taken care to set no more sail than could be shortened at the
briefest notice. He had not been called a moment too soon. A flash
lit the black sky; a peal of thunder rattled like artillery far off; and
then a squall struck the grab with terrific force, and the sea,
suddenly lashed into fury, advanced like a cluster of green liquid
mountains to overwhelm the vessel. She heeled bulwarks under, and
was instantly wrapped in a dense mist, rain pouring in blinding
sheets. The maintopsail was blown away with a report like a gun-
shot; and then, under a reefed foresail, the grab ran before the
wind, which was apparently blowing from the south-east. Furious
seas broke over the deck; the wind shrieked through the rigging; the
vessel staggered and plunged under the shocks of sea and wind.
Fuzl Khan clung to the helm with all his strength, but his arms were
almost torn from their sockets, and he called aloud for Desmond to
come to his assistance.
It was fortunate that little was required of the crew, for in a few
minutes all of them save the four Marathas from the gallivat were
prostrated with sea-sickness. The Babu had run below, and
occasionally, between two gusts, Desmond could hear the shrieks
and groans of the terrified man. But he had no time to sympathize;
his whole energies were bent on preventing the grab from being
pooped. He felt no alarm; indeed, the storm exhilarated him; danger
is bracing to a courageous spirit, and his blood leapt to this contest
with the elements. He thrilled with a sense of personal triumph as he
realized that the grab was a magnificent sea-boat. There was no fear
but that the hull would stand the strain; Desmond knew the pains
that had been expended in her building: the careful selection of the
timbers, the niceness with which the planks had been fitted. No
European vessel could have proved her superior in seaworthiness.
But she was fast drifting out into the Indian Ocean, far away
from the haven Desmond desired to make. How long was this going
to last? Whither was he being carried? Without chart or compass he
could take no bearings, set no true course. It was a dismal prospect,
and Desmond, glowing as he was with the excitement of the fight,
yet felt some anxiety. Luckily, besides the provisions brought in their
bundles by the fugitives, there was a fair supply of food and water
on board; for although every portable article of value had been
taken on shore when the grab anchored in Gheria, it had not been
thought necessary to remove the bulkier articles. Thus, if at the
worst the vessel were driven far out to sea, there was no danger of
starvation even if she could not make port for several days.
But Desmond hoped that things would not come to this pass.
Towards nightfall, surely, the squall would blow itself out. Yet the
wind appeared to be gaining rather than losing strength; hour after
hour passed, and he still could not venture to quit the wheel. He was
drenched through and through with the rain; his muscles ached with
the stress; and he could barely manage to eat the food and water
brought him staggeringly by the serang in the intervals of the wilder
gusts.
The storm had lasted for nearly ten hours before it showed
signs of abatement. Another two hours passed before it was safe to
leave the helm. The wind had by this time fallen to a steady breeze;
the rain had ceased; the sky was clear and starlit; but the sea was
still running high. At length the serang offered to steer while the
others got a little rest; and entrusting the wheel to him, Desmond
and Fuzl Khan threw themselves down as they were, on the deck
near the wheel, and were soon fast asleep.
At dawn Desmond awoke to find the grab labouring in a heavy
sea, with just steering-way on. The wind had dropped to a light
breeze. The Gujarati was soon up and relieved the serang at the
wheel; the rest of the crew, haggard, melancholy objects, were set
to work to make things ship-shape. Only the Babu remained below;
he lay huddled in the cabin, bruised, prostrate, unable to realize that
the bitterness of death was past, unable to believe that life had any
further interest for him.
Desmond's position was perplexing. Where was he? Perforce he
had lost his bearings. He scanned the whole circumference of the
horizon, and saw nothing but the vast dark ocean plain and its
immense blue dome--never a yard of land, never a stitch of canvas.
He had no means of ascertaining his latitude. During the twelve
hours of the storm the grab had been driven at a furious rate; if the
wind had blown all the time from the south-east, the quarter from
which it had struck the vessel, she must now be at least fifty miles
from the coast, possibly more, and north of Bombay. In the inky
blackness of the night, amid the blinding rain, it had been impossible
to read anything from the stars. All was uncertain, save the golden
sheen of sunlight in the east.
Desmond's only course was to put the vessel about and steer by
the sun. She must thus come sooner or later in sight of the coast,
and then one or other of the men on board might recognize a
landmark--a hill, a promontory, a town. The danger was that they
might make the coast in the neighbourhood of one of the Pirate's
strongholds; but that must be risked.
For the rest of the day there were light variable winds, such as,
according to Fuzl Khan, might be expected at that season of the
year. The north-east monsoon was already overdue. Its coming was
usually heralded by fitful and uncertain winds, varied by such squalls
or storms as they had just experienced.
The sea moderated early in the morning, and became
continually smoother until, as the sun went down, there was scarce
a ripple on the surface. The wind meanwhile had gradually veered to
the south-west, and later to the west, and the grab began to make
more headway. But with the fall of night it dropped to a dead calm,
a circumstance from which the Gujarati inferred that they were still a
long way from the coast. When the stars appeared, however, and
Desmond was able to get a better idea of the course to set, a slight
breeze sprang up again from the west, and the grab crept along at a
speed of perhaps four knots.
It had been a lazy day on board. The crew had recovered from
their sickness, but there was nothing for them to do, and as
Orientals they were quite content to do nothing. Only the Babu
remained off duty, in addition to the watch below. Desmond visited
him, and persuaded him to take some food: but nothing would
induce him to come on deck; the mere sight of the sea, he said,
would externalize his interior.
It was Desmond's trick at the wheel between eight and
midnight. Gulam Mahomed was on the look-out; the rest of the crew
were forward squatting on the deck in a circle round Fuzl Khan.
Desmond, thinking of other things, heard dully, as from a great
distance, the drone of the Gujarati's voice. He was talking more
freely and continuously than was usual with him; ordinarily his
manner was morose; he was a man of few words, and those not too
carefully chosen. So prolonged was the monotonous murmur,
however, that Desmond by and by found himself wondering what
was the subject of his lengthy discourse; he even strained his ears to
catch, if it might be, some fragments of it; but nothing came into
distinctness out of the low-pitched drone. Occasionally it was broken
by the voice of one of the others; now and again there was a brief
interval of silence; then the Gujarati began again. Desmond's
thoughts were once more diverted to his own strange fate. Little
more than a year before, he had been a boy, with no more
experience than was to be gained within the narrow circuit of a
country farm. What a gamut of adventure he had run through since
then! He smiled as he thought that none of the folks at Market
Drayton would recognize, in the muscular, strapping, sun-tanned
seaman, the slim boy of Wilcote Grange. His imagination had woven
many a chain of incident, and set him in many a strange place; but
never had it presented a picture of himself in command of as mixed
a crew as was ever thrown together, navigating unknown waters
without chart or compass, a fugitive from the chains of an Eastern
despot. His quick fancy was busy even now. He felt that it was not
for nothing he had been brought into his present plight; and at the
back of his mind was the belief, founded on his strong wish and
hope, that the magnetism of Clive's personality, which he had felt so
strongly at Market Drayton, was still influencing his career.
At midnight Fuzl Khan relieved him at the wheel, and he turned
in. His sleep was troubled. It was a warm night--unusually warm for
the time of year. There were swarms of cockroaches and rats on
board; the cockroaches huge beasts, three times the size of those
that overran the kitchen at home; the rats seeming as large as the
rabbits he had been wont to shoot on the farm. They scurried about
with their little restless noises, which usually would have had no
power to break his sleep; but now they worried him. He scared them
into silence for a moment by striking upon the floor; but the rustle
and clipper-clapper immediately began again.
After vain efforts to regain his sleep, he at length rose and went
on deck. He did not move with intentional quietness, but he was
barefoot, and his steps made no sound. It was a black night, a warm
haze almost shutting out the stars. As he reached the deck he heard
low murmurs from a point somewhere aft. He had no idea what the
time was: Shaik Abdullah had the water-clock, with which he timed
the watches; and Desmond's could not yet be due. Avoiding the spot
where the conversation was in progress, he leant over the bulwarks,
and gazed idly at the phosphorescent glow upon the water. Then he
suddenly became aware that the sounds of talking came from near
the wheel, and Fuzl Khan was among the talkers. What made the
man so uncommonly talkative? Seemingly he was taking up the
thread where it had been dropped earlier in the night; what was it
about?
Desmond asked himself the question without much interest, and
was again allowing his thoughts to rove when he caught the word
"sahib," and then the word "Firangi" somewhat loudly spoken.
Immediately afterwards there was a low hiss from the Gujarati, as of
one warning another to speak lower. The experiences of the past
year had quickened Desmond's wits; with reason he had become
more suspicious than of yore, and the necessity to be constantly on
his guard had made him alert, alive to the least suggestion. Why had
the speaker been hushed--and by Fuzl Khan? He remembered the
ugly rumours, the veiled hints he had heard about the man in
Gheria. If they were true, he had sold his comrades who trusted
him. They might not be true; the man himself had always
indignantly denied them. Desmond had nothing against him. So far
he had acted loyally enough; but then he had nothing to gain by
playing his fellow-fugitives false, and it was with this knowledge that
Desmond had decided to make him privy to the escape. But now
they were clear of Gheria. Fuzl Khan was free like the rest; he had
no longer the same inducement to play straight if his interest
seemed to him to clash with the general. Yet it was not easy to see
how such a clashing could occur. Like the others he was lost at sea;
until land was reached, at any rate, he could have no motive for
opposition or mutiny.
While these thoughts were passing through Desmond's mind he
heard a man rise from the group aft and come forward. Instinctively
he moved from the side of the vessel towards the mainmast, and as
the man drew near Desmond stood so that the stout tree-trunk was
between them. The man went rapidly towards the bows, and in a
low tone hailed the look-out, whispering him a summons to join the
Gujarati at the helm. The look-out, one of the Marathas, left his
post; he came aft with the messenger, and, both passing on the
same side of the vessel, Desmond by dodging round the mast
escaped their notice.
At the best, the action of Fuzl Khan was a dereliction of duty; at
the worst!--Desmond could not put his suspicions into words. It was
clear that something was afoot, and he resolved to find out what it
was. Very cautiously he followed the two men. Bending low, and
keeping under the shadow of the bulwarks, he crept to within a few
feet of the almost invisible group. A friendly coil of rope near the
taffrail gave him additional cover; but the night was so dark that he
ran little risk of being perceived so long as the men remained
stationary. He himself could barely see the tall form of the Gujarati
dimly outlined against the sky.
CHAPTER THE SIXTEENTH
In which a mutiny is quelled in a minute; and our Babu
proves himself a man of war.
Crouching low, Desmond waited. When the Maratha joined the
group Fuzl Khan addressed him directly in a low firm tone.
"We are all agreed, Nanna," he said. "You are the only man
wanting to our purpose. This is the fastest grab on the coast. I know
a port where we can get arms and ammunition; with a few good
men (and I know where they can be found), we can make a strong
band, and grow rich upon our spoils."
"But what about the sahib?"
"Wah! We know what these Firangi are like--at least the
Angrezi.[#] They have the heads of pigs; there is no moving them.
It would be vain to ask the young sahib to join us; his mind is set on
getting to Bombay and telling all his troubles to the Company. What
a folly! And what an injustice to us! It would destroy our chance of
making our fortunes, for what would happen? The grab would be
sold; the sahib would take the most of the price; we should get a
small share, not enough to help us to become rovers of the sea and
our own masters."
[#] English.
"The sahib will refuse, then. So be it! But what then shall we do with
him?"
"He will not get the chance of refusing. He will not be told."
"But he is taking us to Bombay. How then can we work our
will?"
"He thinks he is sailing to Bombay: he will really take us to
Cutch."
"How is that, brother?"
"Does he know Bombay? Of a truth no. He is a boy: he has
never sailed these seas. He depends on us. Suppose we come in
sight of Bombay, who will tell him? Nobody. If he asks, we will say it
is some other place: how can he tell? We will run past Bombay until
we are within sight of Cutch: then truly I will do the rest."
The Maratha did not reply. The momentary silence was broken
by Fuzl Khan again.
"See! Put the one thing in the balance against the other: how
does it turn? On the one side the twenty rupees--a pitiful sum--
promised by the sahib: and who knows he will keep his promise? On
the other, a tenth share for each of you in the grab and whatsoever
prey falls to it."
"Then the Babu is to have a share? Of a truth he is a small man,
a hare in spirit; does he merit an equal share with us? We are
elephants to him."
"No. He will have no share. He will go overboard."
"Why, then, what of the tenth share?"
"It will be mine. I shall be your leader and take two."
Desmond had heard enough. The Gujarati was showing himself
in his true colours. His greed was roused, and the chance of setting
up as a pirate on his own account, and making himself a copy of the
man whose prisoner he had been, had prompted this pretty little
scheme. Desmond crept noiselessly away and returned to his
quarters. Not to sleep; he spent the remainder of his watch below in
thinking out his position--in trying to devise some means of meeting
this new and unexpected difficulty. He had not heard what Fuzl Khan
proposed ultimately to do with him. He might share the Babu's fate:
at the best it would appear that he had shaken off one captivity to
fall into the toils of another. He had heard grim tales of the pirates of
the Cambay Gulf; they were not likely to prove more pleasant
masters than the Marathas farther south, even if they did not prefer
to put him summarily out of the way. His presence among them
might prove irksome, and what would the death of a single English
youth matter? He was out of reach of all his friends; on the Good
Intent none but Bulger and the New Englander had any real
kindness for him, and if Bulger were to mention at any port that a
young English lad was in captivity with the Pirate, what could be
done? Should the projected expedition against Gheria prove
successful, and he not be found among the European prisoners, it
would be assumed that he was no longer living; and even if the
news of his escape was known, it was absurd to suppose that all
India would be searched for him.
The outlook, from any point of view, was gloomy. The Gujarati
had evidently won over the whole ship's company. Were they acting
from the inclination for a rover's life, coupled with hope of gain, or
had they been jockeyed into mutiny by Fuzl Khan? Desmond could
not tell, nor could he find out without betraying a knowledge of the
plot. Then he remembered the Babu. He alone had been excepted;
the other men held him in contempt; but despite his weaknesses, for
which he was indeed hardly accountable, Desmond had a real liking
for him; and it was an unpleasant thought that, whatever happened
to himself, if the plot succeeded Surendra Nath was doomed.
But thinking of this, Desmond saw one ray of hope. He had not
been for long the companion of men of different castes without
picking up a few notions of what caste meant. The Babu was a
Brahman; as a Bengali he had no claim on the sympathies of the
others; but as a Brahman his person to other Hindus was inviolable.
The Marathas were Hindus, and they at least would not willingly
raise their hand against him. Yet Desmond could not be certain on
this point. During his short residence in Gheria he had found that, in
the East as too often in the West, the precepts of religion were apt
to be kept rather in the letter than in the spirit. He had seen the
sacred cow, which no good Hindu would venture to kill for untold
gold, atrociously overworked, and, when too decrepit to be of
further service, left to perish miserably of neglect and starvation. It
might be that although the Marathas would not themselves lay
hands on the Babu, they would be quite content to look calmly on
while a Mohammedan did the work.
At the best, it was Desmond and the Babu against the crew--
hopeless odds, for if it came to a fight the latter would be worse
than useless. Not that Desmond held the man in such scorn as the
men of his own colour. Surendra Nath was certainly timid and slack,
physically weak, temperamentally a coward: yet he had shown
gleams of spirit during the escape, and it seemed to Desmond that
he was a man who, having once been induced to enter upon a
course, might prove both constant and loyal. The difficulty now was
that, prostrated by his illness during the storm, he was not at his
best; certainly in no condition to face a difficulty either mental or
physical. So Desmond resolved not to tell him of the danger
impending. He feared the effect upon his shaken nerves. He would
not intentionally do anything against Desmond's interest, but he
could scarcely fail to betray his anxiety to the conspirators. Feeling
that there was nobody to confide in, Desmond decided that his only
course was to feign ignorance of what was going on, and await
events with what composure he might. Not that he would relax his
watchfulness; on the contrary he was alert and keen, ready to seize
with manful grip the skirts of chance.
Perhaps, he thought, the grab might fall in with a British ship.
But what would that avail? The grab with her extraordinary sailing
powers could show a clean pair of heels to any Indiaman, however
fast, even if he could find an opportunity of signalling for help. Fuzl
Khan, without doubt, would take care that he never had such a
chance.
Turning things over in his mind, and seeing no way out of his
difficulty, he was at length summoned to relieve the Gujarati at the
wheel. It was, he supposed, about four in the morning, and still
pitch-dark. When he came to the helm Fuzl Khan was alone: there
was nothing to betray the fact that the plotters had, but little before,
been gathered around him. The look-out, who had left his post to
join the group, had returned forward, and was now being relieved,
like the Gujarati himself.
Desmond exchanged a word or two with the man, and was left
alone at the wheel. His mind was still set on the problem how to
frustrate the scheme of the mutineers. He was convinced that if the
grab once touched shore at any point save Bombay, his plight would
be hopeless. But how could he guard against the danger? Even if he
could keep the navigation of the grab entirely in his own hands by
remaining continuously at the helm, he was dependent on the
plotters for information about the coast; to mislead him would be
the easiest thing in the world. But it suddenly occurred to him that
he might gain time by altering the course of the vessel. If he kept
out of sight of land he might increase the chance of some diversion
occurring.
Accordingly he so contrived that the grab lost rather than
gained in her tacks against the light north-west wind now blowing.
None of the men, except possibly the Gujarati, had sufficient
seamanship to detect this manoeuvre; he had gone below, and
when he came on deck again he could not tell what progress had
been made during his absence. Only the mainsail, foresail, and one
topsail were set: these were quite enough for the untrained crew to
trim in the darkness--likely to prove too much, indeed, in the event
of a sudden squall. Thus the process of going about was a long and
laborious one, and at the best much way was lost.
Not long after he had begun to act on this idea he was
somewhat concerned to see the serang, who was in charge of the
deck watch, come aft and hang about near the wheel, as though his
curiosity had been aroused. Had he any suspicions? Desmond
resolved to address the man and see what he could infer from the
manner of his reply.
"Is all well, serang?"
"All well, sahib," answered the man. He stopped, and seemed to
hesitate whether to say more; but after a moment or two he moved
slowly away. Desmond watched him. Had he discovered the trick?
Would he go below and waken Fuzl Khan? Desmond could not still a
momentary tremor. But the serang did not rejoin his messmates, nor
go below. He walked up and down the deck alone. Apparently he
suspected nothing.
Desmond felt relieved; but though he was gaining time, he
could but recognize that it seemed likely to profit him little. A
criminal going to execution may step never so slowly across the
prison yard; there is the inexorable gallows at the end, and certain
doom. Could he not force matters, Desmond wondered? It was
evidently to be a contest, whether of wits or of physical strength,
between himself and the Gujarati. Without one or other the vessel
could not be safely navigated; if he could in some way overcome the
ringleader, he felt pretty sure that the crew would accept the result
and all difficulty would be at an end. But how could he gain so
unmistakable an ascendency? In physical strength Fuzl Khan was
more than his match: there was no doubt of the issue of a struggle
if it were a matter of sheer muscular power. For a moment he
thought of attempting to enlist the Marathas on his side. They were
Hindus; the Gujarati was a Muslim; and they must surely feel that,
once he was among his co-religionists in Cutch, in some pirate
stronghold, they would run a very poor chance of getting fair
treatment. But he soon dismissed the idea. The Gujarati must seem
to them much more formidable than the stripling against whom he
was plotting. The Hindu, even more than the average human being
elsewhere, is inclined to attach importance to might and bulk--even
to mere fat. If he sounded the Marathas, and, their fear of the
Gujarati outweighing their inevitable distrust of him as a Firangi,
they betrayed him to curry a little favour, there was no doubt that
the fate both of himself and the Babu would instantly be decided. He
must trust to himself alone.
While he was still anxiously debating the matter with himself his
eye caught the two muskets lashed to the wooden framework
supporting the wheel. He must leave no hostages to fortune. Taking
advantage of a lull in the wind he steadied the wheel with his body,
and with some difficulty drew the charges and dropped them into
the sea. If it came to a tussle the enemy would certainly seize the
muskets; it would be worth something to Desmond to know that
they were not loaded. It was, in truth, but a slight lessening of the
odds against him; and as he restored the weapons to their place he
felt once more how hopeless his position remained.
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!
ebookname.com

More Related Content

PDF
Making use of Python 1st Edition Rashi Gupta
PDF
Making use of Python 1st Edition Rashi Gupta
PDF
Core Servlets and Javaserver Pages Advanced Technologies 2nd Edition Marty Hall
PDF
Core Servlets and Javaserver Pages Advanced Technologies 2nd Edition Marty Hall
PDF
Soap toolkits
PDF
How to develop a gateway service using code based implementation
PDF
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
PDF
Javascript Essentials For Dummies Paul Mcfedries
Making use of Python 1st Edition Rashi Gupta
Making use of Python 1st Edition Rashi Gupta
Core Servlets and Javaserver Pages Advanced Technologies 2nd Edition Marty Hall
Core Servlets and Javaserver Pages Advanced Technologies 2nd Edition Marty Hall
Soap toolkits
How to develop a gateway service using code based implementation
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
Javascript Essentials For Dummies Paul Mcfedries

Similar to Making Use of JSP 1st Edition Madhushree Ganguli (20)

PDF
Net Compact Framework 35 Datadriven Applications Build Robust And Featurerich...
PPT
Bh Win 03 Rileybollefer
PDF
Drools JBoss Rules 5 0 developer s guide develop rules based business logic u...
PDF
Ejb 3 Developer Guide A Practical Guide For Developers And Architects To The ...
PDF
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
PDF
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
PDF
Study Guide Comprehensive Outline for the OutSystems 11 Web Associate Applica...
PDF
Building reliable component based software systems 1st Edition Ivica Crnkovic
PPTX
8-9-10. ASP_updated8-9-10. ASP_updated8-9-10. ASP_updated
PPT
PPT
Jan 2008 Allup
PDF
Aruba ClearPass Guest 6.3 User Guide
PDF
Developer s Guide to Microsoft Enterprise Library C Edition Alex Homer
PDF
E script
PDF
Professional Microsoft Sql Server Analysis Services 2008 With Mdx Sivakumar H...
PPTX
WCF - In a Week
PDF
Web Development With Sas By Example Frederick E Pratter Sas Institute
PPTX
A Web Developer's Journey across different versions of ASP.NET
PDF
ASP.NET 8 Developer Roadmap By ScholarHat PDF
PDF
Building reliable component based software systems 1st Edition Ivica Crnkovic...
Net Compact Framework 35 Datadriven Applications Build Robust And Featurerich...
Bh Win 03 Rileybollefer
Drools JBoss Rules 5 0 developer s guide develop rules based business logic u...
Ejb 3 Developer Guide A Practical Guide For Developers And Architects To The ...
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
Study Guide Comprehensive Outline for the OutSystems 11 Web Associate Applica...
Building reliable component based software systems 1st Edition Ivica Crnkovic
8-9-10. ASP_updated8-9-10. ASP_updated8-9-10. ASP_updated
Jan 2008 Allup
Aruba ClearPass Guest 6.3 User Guide
Developer s Guide to Microsoft Enterprise Library C Edition Alex Homer
E script
Professional Microsoft Sql Server Analysis Services 2008 With Mdx Sivakumar H...
WCF - In a Week
Web Development With Sas By Example Frederick E Pratter Sas Institute
A Web Developer's Journey across different versions of ASP.NET
ASP.NET 8 Developer Roadmap By ScholarHat PDF
Building reliable component based software systems 1st Edition Ivica Crnkovic...
Ad

Recently uploaded (20)

PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
HVAC Specification 2024 according to central public works department
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
advance database management system book.pdf
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
Trump Administration's workforce development strategy
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
Indian roads congress 037 - 2012 Flexible pavement
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
Unit 4 Computer Architecture Multicore Processor.pptx
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
HVAC Specification 2024 according to central public works department
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
FORM 1 BIOLOGY MIND MAPS and their schemes
Weekly quiz Compilation Jan -July 25.pdf
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
advance database management system book.pdf
History, Philosophy and sociology of education (1).pptx
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
LDMMIA Reiki Yoga Finals Review Spring Summer
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Trump Administration's workforce development strategy
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Indian roads congress 037 - 2012 Flexible pavement
Ad

Making Use of JSP 1st Edition Madhushree Ganguli

  • 1. Making Use of JSP 1st Edition Madhushree Ganguli download https://ebookname.com/product/making-use-of-jsp-1st-edition- madhushree-ganguli/ Get Instant Ebook Downloads – Browse at https://ebookname.com
  • 2. Instant digital products (PDF, ePub, MOBI) available Download now and explore formats that suit you... JSP Practical Guide for Programmers 1st Edition Robert Brunner https://ebookname.com/product/jsp-practical-guide-for- programmers-1st-edition-robert-brunner/ JSTL Practical Guide for JSP Programmers 1st Edition Sue Spielman https://ebookname.com/product/jstl-practical-guide-for-jsp- programmers-1st-edition-sue-spielman/ Technology Transfer in Biotechnology A Global Perspective 1st Edition Prabuddha Ganguli https://ebookname.com/product/technology-transfer-in- biotechnology-a-global-perspective-1st-edition-prabuddha-ganguli/ Race and Ethnicity in Latin America 2nd Edition Peter Wade https://ebookname.com/product/race-and-ethnicity-in-latin- america-2nd-edition-peter-wade/
  • 3. Goddess Traditions in Tantric Hinduism History Practice and Doctrine 1st Edition Bjarne Wernicke Olesen (Editor) https://ebookname.com/product/goddess-traditions-in-tantric- hinduism-history-practice-and-doctrine-1st-edition-bjarne- wernicke-olesen-editor/ Women s Studies A Recommended Bibliography Third Edition Linda A. Krikos https://ebookname.com/product/women-s-studies-a-recommended- bibliography-third-edition-linda-a-krikos/ The Act of Remembering Toward an Understanding of How We Recall the Past 1st Edition John H. Mace https://ebookname.com/product/the-act-of-remembering-toward-an- understanding-of-how-we-recall-the-past-1st-edition-john-h-mace/ Ethical trade a comprehensive guide for companies Second Edition Ethical Trading Initiative https://ebookname.com/product/ethical-trade-a-comprehensive- guide-for-companies-second-edition-ethical-trading-initiative/ A Computational Introduction to Number Theory and Algebra Victor Shoup https://ebookname.com/product/a-computational-introduction-to- number-theory-and-algebra-victor-shoup/
  • 4. Themes of the American Civil War The War Between the States Revised Second Edition Susan-Mary Grant https://ebookname.com/product/themes-of-the-american-civil-war- the-war-between-the-states-revised-second-edition-susan-mary- grant/
  • 6. Madhushree Ganguli Making Use of JSP Wiley Publishing, Inc.
  • 10. Madhushree Ganguli Making Use of JSP Wiley Publishing, Inc.
  • 11. Publisher: Robert Ipsen Editor: Ben Ryan Developmental Editor: Kathryn A. Malm Managing Editor: Angela Smith New Media Editor: Brian Snapp Text Design & Composition: John Wiley Production Services Designations used by companies to distinguish their products are often claimed as trade- marks. In all instances where John Wiley & Sons, Inc., is aware of a claim, the product names appear in initial capital or ALL CAPITAL LETTERS. Readers, however, should contact the appro- priate companies for more complete information regarding trademarks and registration. This book is printed on acid-free paper. ∞ Copyright © 2002 by Madhushree Ganguli. All rights reserved. Published by Wiley Publishing, Inc., New York 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 Sections 107 or 108 of the 1976 United States Copy- right 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, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4744. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 605 Third Avenue, New York, NY 10158-0012, (212) 850-6011, fax (212) 850-6008, E-Mail: PERMREQ @ WILEY.COM. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold with the understanding that the publisher is not engaged in professional services. If professional advice or other expert assistance is required, the services of a competent professional person should be sought. Library of Congress Cataloging-in-Publication Data: ISBN 0-471-21974-6 Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic versions. For more information about Wiley prod- ucts, visit our Web site at www.wiley.com. Printed in the United States of America. 10 9 8 7 6 5 4 3 2 1
  • 12. Introduction xv Scenario xxiii Chapter 1 Introducing Web Development 1 Getting Started 1 Internet Basics 2 The Two-Tier Architecture 5 The Three-Tier Architecture 6 How the Internet Works 8 The Internet Addressing Scheme 8 The World Wide Web 9 Web Browsers 11 The HTTP Request 14 Summary 16 Chapter 2 Introducing Java Server Pages 17 Getting Started 17 Java Server Pages 19 JSP Life Cycle 20 Comparing JSP with Existing Technologies 22 JSP and Servlets 22 JSP and ASP 23 Setting Up the J2EE Environment 25 Verify the Hardware Configuration of the Computers 25 Identify the Components to Be Installed 26 Install the Java Development Kit 26 Install the Server 27 Set the Environment 27 Test the Server 30 Summary 32 Contents v
  • 13. Chapter 3 Servlet Basics 35 Getting Started 35 Introduction to Servlets 38 Working of a Servlet 38 Characteristics of Servlets 39 Java Servlet Architecture 40 Servlet Class Hierarchy 41 Life Cycle of a Servlet 42 Servlets and Other Server-Side Scripting Technologies 44 Sevlets and CGI Scripts 44 Servlets and Active Server Pages (ASP) 44 Creating a Servlet 45 Identify the Mechanism for Accepting and Displaying the Details 46 Identify the Classes to Be Used 46 Identify the Methods to Be Used 46 Write the Code for the Servlet 46 Compile the Servlet Code 47 Deploy the Servlet 48 Execute the Servlet 53 Summary 55 Chapter 4 Creating a JSP Page 57 Getting Started 57 Components of a JSP Page 58 HTML Tags 59 JSP Tags 59 Generating Static Content by Using JSP 61 Identify the Basic HTML Components of the Code 61 Identify the Basic JSP Components of the Code 61 Formulate the Acknowledgment Statement for the JSP Page 64 Write the Code for the Application 65 Execute the Code 65 View the JSP Page 66 Generating Dynamic Content by Using JSP 67 Identify the Basic JSP Components of the Code 67 Write the Code for the Application 67 Execute the Code 68 View the JSP Page 68 Summary 69 Chapter 5 Using JSP Directives and Action Elements 71 Getting Started 71 JSP Directives 72 vi Contents
  • 14. Using JSP Directives 73 Identify the Data That Needs to Be Accepted for the Login Screen 74 Design the User Interface Screen for the Login Page 75 Identify the JSP Tag to Add the Bank’s Name and Logo to the Login Page 75 Write the HTML Code for the Login Page 82 Add the Tag-Specific Line of Code to the Login Page Code 83 Execute the Code 84 View the JSP Page 84 Standard Actions 86 Using JSP Standard Actions 87 Identify the Mechanism to Be Used 88 Identify the JSP Tag to Add the Content of the Schedule to the Login Page 98 Add the Tag-Specific Line of Code to the Login Page Code 98 Execute the Code 99 View the JSP Page 99 Change the Date and Time of the Schedule to Verify It Has Been Updated in the JSP Page 99 Summary 101 Chapter 6 Working with HTML Forms 103 Getting Started 103 HTML Forms 104 Creating an HTML Form 105 Identify the Components for the User Interface 105 Identify the HTML Form Elements for the User Interface 106 Identify the Mechanism for Transfer of Data 124 Write the Code for the HTML Form 125 View the HTML Form 127 Validate the Form Data Values 128 Write the HTML Code to Validate User Input 129 Submit the Form to Validate the Data in the Form 131 Summary 131 Chapter 7 Implicit Objects 133 Getting Started 133 Implicit Objects 134 Using JSP Implicit Objects 135 Identify the Components of the Welcome Page 135 Identify the HTML Form Elements 136 Identify the JSP Elements for Creating the Personalized Message 137 Contents vii
  • 15. Write the Code to Display the Personalized Message 146 Execute the Code 148 View The JSP Page 148 Using the JSP out Object 149 Identify the Components of the HTML Page 149 Identify the HTML Form Elements 150 Identify the JSP Elements to Be Included in the Acknowledgment Page 150 Write the Code for the HTML Form 151 Write the Code for the JSP Page 152 Execute the Code 152 View the JSP Page 153 Summary 154 Chapter 8 Using Scripting Elements 155 Getting Started 156 Scripting Elements 156 Using JSP Scripting Elements 157 Identify the Components of the Page 157 Identify the Elements of the HTML File 158 Identify the Elements of the JSP Page 159 Write the Code for the HTML file 168 Write the Code for the JSP Page 169 Execute the Code 170 View the JSP Page 171 Summary 172 Chapter 9 JSP and JavaBeans 173 Getting Started 173 A Bean Component 174 JavaBeans 175 Handling Changes in the Bean Property 177 Identify the Mechanism to Be Used to Validate the Change in the Account Type 178 Identify the Classes and Methods to Be Used 178 Write the Code for the Bean 179 Write the Code for the Listener Bean 180 Add the Bean to an Application 181 Compile and Execute the Programs 182 Verify the Execution of the Program 182 A JSP Example Using JavaBeans 186 Identify the Mechanism for Displaying Account Type Details Based on the User Input 187 Identify the Elements of the User Interface Screen 187 viii Contents
  • 16. Identify the Tags for the JSP Page 188 Identify the Components of a Bean 194 Write the Code for the HTML Page 194 Write the Code for the JSP Page 195 Write the Code for a Bean 195 Compile the Java File 196 View the JSP Page 197 Summary 198 Chapter 10 Implementing JDBC Connectivity 201 Getting Started 201 Database Management and Connectivity 202 Introduction to SQL 203 Database Connectivity in Java 207 The JDBC Database Access Models 208 Types of JDBC Drivers 210 Accessing a Database from a JSP Page 212 Identify the Elements of the Input Page 216 Identify the Steps for Connecting to the Database 216 Identify the Statements to Create a Table for the Registration Entries 218 Identify the SQL Query for Inserting Customer Details 221 Write the Code to Create a Table in the Database 222 Write the Code to Insert the Registration Details in the Table 223 Create a DSN for the Database 224 Execute the Code to Create the Table in the Database 228 Execute the Code to Insert Data in the Table 228 Verify the Data in the Database 230 Summary 233 Chapter 11 Building JDBC Applications 235 Getting Started 235 Creating a JSP Page 236 Identify the Various Files to Be Used for Validating User Input 237 Identify the Elements of the User Interface 237 Identify the Classes and Methods of the Bean Component 240 Identify the Elements of the JSP Page for Referencing the Bean Component 240 Write the Java Code for the Bean 241 Write the Code for the JSP Page with the Bean Reference 243 Compile the Code for the Bean Component 243 View the JSP Page 244 Connection Pooling in JSP 245 Contents ix
  • 17. Displaying Records from the Database by Using Connection Pooling 246 Identify the Elements of the JSP Page 247 Identify the Various Java Files to Be Used for Creating a Connection Pool 248 Identify the Tags for the JSP Page 257 Write the Java Code for the ConnectionPool Class 257 Write the Java Code for the DriverUtilities Class 261 Write the Java Code for the DatabaseUtilities Class 263 Write the Java Code for the DBResults Class 268 Write the Code for the Servlet Utilities 271 Write the Code for the JSP Page 273 Compile the Java Files 274 View the JSP Page 275 Summary 275 Chapter 12 Handling Errors 277 Getting Started 277 Handling Errors in JSP 278 Creating an Error Page 279 Design the User Interface to Accept Information from Customers 279 Identify the Structure of an Error Page 280 Identify the Tag to Link an Error Page to a JSP Page 281 Identify the Components of the JSP Page to Calculate the Returns on Investments 281 Write the Code for the User Interface 283 Write the Code for the JSP Page to Calculate the Returns on Investments 283 Write the Code to Display the Error Messages 284 View the JSP Page 285 Generating Customized Error Messages 287 Identify the Additional Inclusions in the JSP Page to Catch Exceptions 288 Identify the Additional Inclusions in the Error Page to Display Customized Error Messages 289 Write the Code for the JSP Page to Catch Exceptions 289 Write the Code for the Error Page 290 View the JSP Page 291 Summary 292 Chapter 13 JSP Sessions 293 Getting Started 293 The Session Tracking API 294 Using Cookies for Session Tracking 295 x Contents
  • 18. Identify the Elements of the Home Page 296 Identify the JSP Tags to Be Included in Order to Display the Personalized Hit Count 298 Write the Code for the JSP Page 302 View the JSP Page 305 Session Tracking by Using Hidden Form Fields 306 Using a Session Object for Session Tracking 308 Identify the HTML Elements of the Page 309 Identify the JSP Tags to Be Included in Order to Display the Entries for the List 311 Write the Code for the JSP Page 315 View the JSP Page 317 Using URL Rewriting for Session Tracking 318 Identify the HTML Elements of the Page 319 Identify the JSP Tags to Be Included in Order to Display the Hit Count 320 Write the Code for the JSP Page 323 View the JSP Page 325 Summary 326 Chapter 14 JSP and XML 327 Getting Started 327 Introducing XML 328 XML versus Relational Databases 329 XML versus HTML 329 XML versus SGML 332 Basic Rules to Create XML Documents 332 Document Type Definition 333 XML Namespaces 336 XML Schemas 336 Extensible Stylesheet Language Transformations (XSL/T) 338 Benefits of XML 340 Generating Dynamic Content in the XML Format 341 Identify the Customer Details to Be Included in the XML Document 342 Identify the Tags to Be Added to the XML Document 342 Identify the JSP Tag to Be Added to the Document 343 Identify the Java Code to Be Added to the Document 343 Write the Code for the XML Document 344 Write the Code for the JSP Page 345 View the JSP Page 346 APIs to Access XML Data 347 Document Object Model 349 Simple API for XML 350 Contents xi
  • 19. Consuming XML Data 351 Identify Interfaces, Classes, and Methods 352 Write the Code to Implement Handlers 352 Test the Code 355 Use the Parser Bean from a JSP Page 356 View the JSP Page 357 Summary 358 Chapter 15 Developing Custom Tags 359 Getting Started 359 Custom Tags 360 Need for XML 361 Advantages of Tag Libraries 363 Structure of a Custom Tag 363 Components of a Tag Library 364 The Tag Handler Class 364 The Tag Library Descriptor File 365 The JSP file 365 Developing Simple Tags 366 Identify the Components of the Tag Library 367 Identify the Structure of the Tag Handler Class 367 Identify the Structure of the TLD File 370 Identify the Additional Inclusions in the JSP File 372 Write the Code for the Tag Handler Class 373 Write the Code for the TLD File 373 Write the Code for the JSP File 374 Compile the Tag Handler Class 375 Deploy the Tag Library 375 View the JSP Page 377 Developing a Tag for Database Interaction 386 Identify the Components of the Tag Library 387 Identify the Structure of the Tag Handler Class 387 Identify the Structure of the TLD File 387 Identify the Additional Inclusions in the JSP File 388 Write the Code for the Tag Handler Class 388 Write the Code for the TLD File 390 Write the Code for the JSP File 390 Compile the Tag Handler Class 391 Deploy the Tag Library 391 View the JSP Page 391 Summary 392 xii Contents
  • 20. Chapter 16 JavaMail 395 Getting Started 395 Introduction to the JavaMail API 396 Using JavaMail in JSP 397 Identify the Elements of the HTML Page to Accept the Details of the Mail 398 Identify the Elements of the JSP Page to Add the JavaMail Functionality to the Application 399 Write the Code for the HTML Page 405 Write the Code for the JSP Page 406 View the JSP Page 407 Summary 409 Index 411 Contents xiii
  • 22. The world seems to shrink each day, thanks to the ever-increasing power of the Inter- net. With the growth and popularity of the Internet, even distant areas across the globe seem closer today. It is indeed the era of fast communication and information exchange. To retain a commanding position in this changing world, organizations need to prepare themselves for the rapid development of Web-based applications that are platform- independent. As a result, organizations need to identify the tools required to emerge as a formidable force in the competitive world of Web-based applications. Java Server Pages, or JSP, a Sun Microsystems product, is one tool that is fast catching up as a pre- ferred technology for creating Web-based applications. JSP is based on the Java technology and is an extension of the Java Servlet technology. As a result, platform independence and extensibility of servlets are easily incorporated in JSP. In addition, using the Java server-side modules, JSP can fit effortlessly into the framework of a Web server with minimal overhead, maintenance, and support. The use of XML-like tags and Java-like syntax in JSP facilitate building Web-based applica- tions with speed and ease as never before. The power, extensibility, and portability of JSP are well described by the following statements from Sun Microsystems: The JSP specification is the product of industry-wide collaboration with industry leaders in the enterprise software and tools market, led by Sun Microsystems. Sun has made the JSP specification freely available to the development community with the goal that every Web server and application server will support the JSP interface. Future Direction By working with a consortium of industry leaders, Sun has ensured that the JSP specifica- tions remain open and portable. Over time, tool vendors and others will extend the func- tionality of the platform by providing customized tag libraries for specialized functions. It is beyond doubt that JSP will rule the market in the future and become one of the most powerful languages for developing Web applications. The use of customized tags Introduction xv
  • 23. and libraries is gaining wide acceptance in the industry as a flexible mechanism that allows segregation of the work profiles of the page author and the programmer. Along with conceptual information, this book will also provide extensive practical exercises for the reader to gain valuable real-life exposure in creating different types of applications. The aim of this book is to make learning an enjoyable and energizing process. Overview of JavaServer Pages Two friends, Gwen and Griffith, decide to enroll themselves in a short course during the fall break. While Gwen’s choice is interior decoration, Griffith chooses a more pro- fessional course in secretarial practice. Both friends, being computer savvy, search the Internet and come up with the same site advertising their choices of short courses. As an afterthought, both Gwen and Griffith marveled that although their choice of courses was different, the same site displayed a list of details for the two completely different courses. How was the display of the courses linked and changed according to the search criteria? What actually ensued was a request-response cycle that displayed the result pertaining to the individual query. In other words, the Web application for the site received the requests and returned dynamic content in the form of the course details. In the world of the Internet, dynamism is part and parcel of Web applications. Technologies such as Hypertext Pre Processor (PHP), Active Server Pages (ASP), and Java Server Pages (JSP) are used to create dynamic Web applications. This book will help you understand the JSP technology that can be used to create applications to generate dynamic content. Java Server Pages allows Web developers and designers to develop easily maintainable, information-rich, dynamic Web pages. Java Server Pages separates the user interface from content generation. This enables designers to change the layout of a Web page without altering the underlying dynamic content. As a result, the workload can be clearly separated into two categories, the graphical content created by a designer or a page author and the dynamic content cre- ated by the developer or the programmer. As a result, in simple words, JSP provides a simplified, faster way to create dynamic Web content. History of JSP Sun Microsystems was founded in 1982. Ever since its inception, Sun Microsystems has maintained a singular vision of “The Network Is The Computer.” This vision has helped Sun Microsystems remain as one of the leading providers of industrial-strength hardware, software, and services to aid companies across the world. The company has a global presence in more than 170 countries with gross annual revenue crossing the $17 billion mark. A significant year in the history of Sun Microsystems was 1995. This was the year when Sun received ISO 9001 certification for quality in all major country service orga- nizations and ISO 9002 certification for all worldwide manufacturing operations. In the same year, the company unleashed Java technology, which was the first universal software platform designed for the Internet and corporate intranets. Java technology xvi Introduction
  • 24. enabled developers to write applications once and run them on computers anywhere without any modifications. If we flip back the pages of the history of Java, we’ll realize that the introduction of Java was more of an accident. In fact, you’ll be surprised to know that Java was originally developed not for computers but for home appliances such as ovens, toasters, and refrigerators. The accident, though, has proved to be a boon in disguise—with the popularity of the Internet neither Sun nor Java has had to look back. Java has worked hard to be accepted and recognized as a favorite language for developing Web applications. JSP is a part of the Java family that shares the key characteristics of the Java technol- ogy: “Write Once, Run Anywhere.” It is a core component of the Java 2 Enterprise Edi- tion. JSP has inherited most of the features and benefits of both Java and Servlet technology and is fast gaining acceptance as a standard tool for building dynamic Web sites. Features of JSP JSP provides an attractive alternative to other dynamic scripting languages by offering the following features: Platform independence. The use of JSP adds versatility to a Web application by enabling its execution on any computer. Enhanced performance. The compilation process in JSP produces faster results or output. Separation of logic from display. The use of JSP permits the HTML-specific static content and a mixture of HTML, Java, and JSP-specific dynamic content to be placed in separate files. Ease of administration. The use of JSP eliminates the need for high-level techni- cal expertise, thereby helping Web developers, designers, content creators, and content managers to work together and develop Java-based applications in less time and with less effort. Ease of use. All JSP applications run on major Web servers and operating sys- tems, including Microsoft IIS, Netscape Enterprise Server, iPlanet Web Server, and Apache Web Server. These applications are also available on Windows NT, Windows 2000, and Solaris 7. Users of the Product/Technology By moving Web development into the twenty-first century, Java Server Pages technol- ogy enables faster product delivery time. Here are a few examples of enterprises that are using the Java Server Pages framework to deliver break-away business strategies for both themselves and their customers: ■ ■ Knight Ridder ■ ■ Delta Airlines Introduction xvii
  • 25. ■ ■ Waterstone Consulting ■ ■ Axtive Software Corporation ■ ■ MetaMarkets.com, Inc. ■ ■ Cambridge Interactive ■ ■ NMG New Media Group ■ ■ Epicentric, Inc. ■ ■ PostalWorks LLC ■ ■ Flashline.com, Inc. ■ ■ TheWorksUSA.com ■ ■ Klicman Incorporated ■ ■ TouchNet Information Systems, Inc. ■ ■ Linnebank IT ■ ■ Tradiant Competing Products across Platforms Competing products include Active Server Pages (ASP), Hypertext Pre Processor (PKP), and JavaScript. JSP versus ASP. ASP is the immediate competing technology from Microsoft. The dynamic content of JSP is written in Java, in contrast to that of ASP, which is written using an ASP-specific language, such as VBScript. As a result, complex applications can use the power of Java to reuse and embed Java components in JSP applications. Second, JSP is portable to other operating systems and servers in contrast to the allegiance of ASP to Windows NT/2000 and IIS. JSP versus PHP. PHP is similar to ASP and JSP to a certain extent. PHP is a free, open-source, HTML-embedded, server-side scripting language. With basic HTML knowledge, however, a VBScript programmer can write ASP applica- tions and a Java programmer can create JSP applications, whereas PHP requires learning an entirely new language. Second, by virtue of the power of Java, JSP has access to an extensive API for networking, database access, and object distribution. JSP versus JavaScript. JavaScript is a programming language that is totally different from the server-side HTML and Java-based JSP technology. JavaScript is a client-side programming language used to build parts of HTML Web pages while the browser loads a document. As a result, the pages generated in JavaScript create dynamic content that is solely based on the client environment. JSP applications, by virtue of its being a server-side scripting language, use mechanisms such as hidden fields, session objects, cookies, and URL rewriting to access all request data transmitted during a request-response cycle. Equipped with only cookies as aids to provide request data, the client-side JavaScript xviii Introduction
  • 26. routines are unable to access the HTTP request data. Although JavaScript can be used on servers as a scripting language for IIS, JSP backed by the reliability, flexibility, and portability of Java is a more powerful technology by far. How This Book Is Organized This book differs from the traditional content-based approach and uses the problem- based approach to deliver the concepts of JSP. Problems used in the book are presented against the backdrop of real-life scenarios. The problem is followed by a task list that helps to solve the given problem, in the process explaining the concepts and their implementation. This practical approach will help readers understand the real-life application of the language and its use in various scenarios. Moreover, to provide an appropriate learning experience, the concepts will be supported adequately by case studies that provide a frame of reference for the reader. Chapter 1 is a guide to the basics of the Internet and discusses the World Wide Web environment, browser and server interactions, and the HTTP request-response cycle. Chapter 2 is a getting-started guide that begins with a brief introduction to JSP. This is followed by a discussion on the JSP life cycle and concludes with the steps used for installing and setting up the environment to execute JSP applications. Chapter 3 attempts to highlight the advantages incorporated in JSP as an extension of Java Servlet technology. The chapter begins with a discussion of the JavaServlet architecture and life cycle. The chapter concludes with an example of a simple servlet that is used to count the number of hits for a particular page. Chapter 4 introduces concepts related to creating a JSP application. It discusses the various components of a JSP page by using the simple “Hello World” example. The difference between static and dynamic content is also discussed using appropriate examples. Chapter 6 delves into the all-important concept of HTML forms. All user-specific input is transferred to the server by using various controls of the HTML page. The chapter begins with an introduction to HTML forms, followed by a discussion of the various types of HTML controls that can be added to a form. Next, the mechanisms of retrieval and transfer of form values in JSP are discussed using a simple example. The chapter concludes with a JavaScript-aided client-side validation for ensuring user input in a form control. Chapters 6, 7, and 8 discuss the different JSP-specific components one by one. Chap- ter 5 discusses implicit objects, including such implicit objects as request, response, ses- sion, application, and config. This is followed by a brief discussion of the importance of the scope of implicit objects. Chapter 7 discusses two JSP components, directives and action elements. The chap- ter begins with the types and uses of the page, include, and taglib directives. Next, the various JSP standard actions are discussed with suitable examples. In the concluding section of the chapter, examples are used to show the difference in the usage of the include directive and the include standard action. Introduction xix
  • 27. Chapter 8 introduces the scripting elements of JSP that are primarily used to gener- ate the dynamic content. It discusses the use of the three types of scripting elements: scriplets, expressions, and declarations. Chapter 9 explains concepts relating to reusing Java bean components in a JSP page. The chapter begins with an introduction to JavaBeans, followed by a discussion on using JavaBeans in JSP. To aid a better understanding of using a bean component in a JSP page, the chapter concludes with an example that uses a Java bean instead of a direct use of JSP components to display dynamic content. Chapter 10 moves on to discussing activities on the server side. This chapter assumes that the reader has a basic knowledge of databases, data storage in databases, RDBMS concepts, and their implementation. The chapter begins with a discussion of concepts pertaining to JDBC basics that include types of JDBC drivers, the various application architecture, and database access models. Next, the chapter explains the processes of accessing and manipulating a database by using SQL commands. Finally, a JSP appli- cation is used as a backdrop to implement database connectivity and discuss concepts such as connecting to a database, creating a table in a database, and inserting records in a database. Chapter 11 combines the concepts of reusing bean components to implement data- base interactions in JSP applications. The chapter begins with an example of a login bean that is used to validate and authenticate a user. Next, the concept of connection pooling is discussed to highlight the importance of economizing the use of Web resources during a database interaction. The chapter then discusses the various classes and methods required to create a connection pool in a JSP application. Chapter 12 delves into handling errors in JSP. The chapter begins with a discussion of error handling and the implementation of exception handling in JSP. Next, the trans- lation and request time errors are discussed with examples. Chapter 13 introduces another important concept of session tracking. The chapter begins by differentiating between a stateful and stateless session and the importance of the availability of session-related information in applications. It then discusses the methods of using cookies, hidden fields, session-tracking APIs, and URL rewriting for session tracking. Chapter 14 further discusses the advanced Web programming concepts of using Simplified API for XML (SAX) and Extensible Markup Language (XML) in JSP appli- cations. To start with, this chapter discusses the benefits of using XML. This is followed by a discussion of the SAX API and the use of various classes and methods of the SAX API to parse the contents of an XML document in JSP. Chapter 15 delves into developing the relatively new concept of custom tags. This chapter discusses the need of custom tags in JSP to encapsulate recurring code snip- pets. The chapter uses examples to discuss in detail the various formats that can be adopted to add both simple and complex tags in a JSP application. In addition, the chapter also includes an example that uses a custom tag to initiate a database interac- tion for retrieving and displaying a particular record from the database. Chapter 16, the final chapter, is a brief introduction to JavaMail and the importance of mailing services in our lives today. The chapter wraps up with an example that cre- ates an application for sending a message by using the class and method declarations of the JavaMail API. xx Introduction
  • 28. Who Should Read This Book This book is a guide for readers with basic familiarity with HTML and the Java lan- guage. In this book the content will be covered using lucid examples, sample codes, and the appropriate use of visuals and demonstrations. The concepts will be supported adequately by case studies that will be formulated in such a way that they provide a frame of reference for the reader. Problems will be presented to the reader against the backdrop of real-life scenarios. The practical approach will help readers to understand the real-life application of the language and the use of JSP in various scenarios. In a nutshell, this book will provide a starting point for working with and creating applica- tions in JSP. This book is intended for programmers interested in developing dynamic Web sites by using JSP. The target audience for this book would include the following: ■ ■ Web application developers ■ ■ Technical support professionals ■ ■ Web site administrators Novice developers of Web applications can use relevant real-world-oriented scenar- ios and exercises for the concepts covered as a guide to learn the basics of writing Java Server Pages. Tools You Will Need For performing the tasks in this book, you will need a Pentium or faster computer with a minimum 32MB RAM (64MB RAM recommended). You will also need the following software: Operating system: Windows NT 4.0 with Service Pack 6.0. RDBMS: SQL 7.0. Text Editors: Notepad or Edit Plus, for example. Software: Java Development Kit (v 1.3). Software: Java 2 SDK, Enterprise Edition (v 1.2.1). What’s on the Web Site The following will be available on the site www.wiley.com/compbooks/makinguse: ■ ■ Java Development Kit (v 1.3) ■ ■ Java 2 SDK, Enterprise Edition (v 1.2.1) ■ ■ All the code snippets used in the book Introduction xxi
  • 30. Exploring the Variety of Random Documents with Different Content
  • 31. vessels could be distinctly seen; and mingled with the myriad noises from the shore was now the crackle of the flames, and the hiss of burning spars and rigging as they fell into the water. The gallivats had separated into two groups; either they had been cut apart, or, more probably, the lashings had been burnt through. Around one of the groups Desmond saw a number of small boats. They appeared to be trying to cut out the middle of the three gallivats, which seemed to be as yet uninjured, while the vessels on either side were in full blaze. Owing to the intense heat the men's task was a difficult and dangerous one, and Desmond had good hope that they would not succeed until the gallivat was too much damaged to be of use for pursuit. He wondered, indeed, at the attempt being made at all; for it kept all the available boats engaged when they might have dashed upon the grab in tow and made short work of it. The true explanation of their blunder did not at the moment occur to Desmond. The fact was that the men trying so earnestly to save the gallivat knew nothing of what had happened to the grab. They were aware that a gallivat had been cut loose and was standing out to sea; but the glare of the fire blinded them to all that was happening beyond a narrow circle, and as yet they had had no information from shore of what was actually occurring. When they did learn that two vessels were on their way to the sea, they would no doubt set out to recapture the fugitives instead of wasting their efforts in a futile attempt to save the unsavable. Desmond was still speculating on the point when another shot from the fort aroused him to the imminent danger. The dark shapes of the two vessels must now certainly be visible from the walls. The shot flew wide. Although the grab was well within range it was
  • 32. doubtless difficult to take aim, the distance being deceptive and the sights useless in the dark. But this shot was followed at intervals of a few seconds by another and another; it was clear that the fugitives were running the gauntlet of the whole armament on this side of the fort. The guns were being fired as fast as they could be loaded; the gunners were becoming accustomed to the darkness, and when Desmond heard the shots plumping into the water, nearer to him, it seemed, every time, he could not but recognize that success or failure hung upon a hair. Crash! A round shot struck the grab within a few feet of the wheel. A shower of splinters flew in all directions. Desmond felt a stinging blow on the forehead; he put up his hand; when he took it away it was wet. He could not leave the wheel to see what damage had been done to the ship, still less to examine his own injury. He was alone on board. Every other man was straining at his oar in the gallivat. He felt the blood trickling down his face; from time to time he wiped it away with the loose end of his dhoti. Then he forgot his wound, for two more shots within a few seconds of each other struck the grab forward. Clearly the gunners were aiming at his vessel, which, being larger than the gallivat, and higher in the water, presented an easier mark. Where had she been hit? If below the waterline, before many minutes were past she would be sinking under him. Yet he could do nothing. He dared not order the men in the gallivat to cease rowing; he dared not leave the helm of the grab; he could but wait and hold his post. It would not be long before he knew whether the vessel had been seriously hit: if it was so, then would be the time to cast off the tow-rope.
  • 33. The gallivat, at any rate, appeared not to have suffered. Desmond was beginning to think he was out of the wood when he heard a crash in front, followed by a still more ominous sound. The motion of the gallivat at once ceased, and, the grab slowly creeping up to her, Desmond had to put his helm hard up to avoid a collision. He could hear the Gujarati raging and storming on deck, and cries as of men in pain; then, as the grab came abreast of the smaller vessel, he became aware of what had happened. The mainmast of the gallivat had been struck by a shot and had gone by the board. Desmond hailed the Gujarati and told him to get three or four men to cut away the wreckage. "Keep an eye on the prisoners," he added, feeling that this was perhaps the most serious element in a serious situation; for with round shot flying about the vessel it might well have seemed to the unhappy men on the rowing benches that mutiny was the lesser of two risks. But the rowers were cowed by the presence of the two Biluchis armed with their terrible knives, and they crowded in dumb helplessness while the tangled rigging was cut away. "Is any one hurt?" asked Desmond. "One of the rowers has a broken arm, sahib," replied Shaik Abdullah. "And I have a contusion of the nose," said the Babu lugubriously. It was impossible to do anything for the sufferers at the moment. It was still touch-and-go with the whole party. The shots from the fort were now beginning to fall short, but, for all Desmond knew, boats might have been launched in pursuit, and if he was overtaken it meant lingering torture and a fearful death. He was in a
  • 34. fever of impatience until at length, the tangled shrouds having been cut away, the rowing was resumed and the two vessels began again to creep slowly seaward. Gradually they drew out of range of the guns. Steering straight out to sea, Desmond had a clear view of the whole of the harbour and a long stretch of the river. The scene was brightly lit up, and he saw that two of the gallivats had been towed away from the burning vessels, from which the flames were now shooting high into the air. But even on the two that had been cut loose there were spurts of flame; and Desmond hoped that they had sustained enough damage to make them unseaworthy. Suddenly there were two loud explosions, in quick succession. A column of fire rose towards the sky from each of the gallivats that were blazing most brightly. The fire had at length reached the ammunition. The red sparks sprang upwards like a fountain, casting a ruddy glow for many yards around; then they fell back into the sea, and all was darkness, except for the lesser lights from the burning vessels whose magazines had as yet escaped. The explosions could hardly have occurred at a more opportune moment, for the darkness was now all the more intense, and favoured the fugitives. There was a brisk breeze from the south-west outside the harbour, and when the two vessels lost the shelter of the headland they crept along even more slowly than before. Desmond had learnt enough of seamanship on board the Good Intent to know that he must have sea-room before he cast off the gallivat and made sail northwards; otherwise he would inevitably be driven on shore. It was this fact that had prompted his operations in the harbour. He
  • 35. knew that the grabs could not put to sea unless they were towed, and the gallivats being rendered useless, towing was impossible. The sea was choppy, and the rowers had much ado to control the sweeps. Only their dread of the Biluchis' knives kept them at their work. But the progress, though slow, was steady; gradually the glow in the sky behind the headland grew dimmer; though it was as yet impossible to judge with certainty how much offing had been made, Desmond, resolving to give away no chances, and being unacquainted with the trend of the coast, kept the rowers at work, with short intervals of rest, until dawn. By this means he hoped to avoid all risk of being driven on a lee shore, and to throw Angria off the scent; for it would naturally be supposed that the fugitives would head at once for Bombay, and pursuit, if attempted, would be made in that direction. When day broke over the hills, Desmond guessed that the coast must be now five miles off. As far as he could see, it ran north by east. He had now plenty of sea-room; there was no pursuer in sight; the wind was in his favour, and if it held, no vessel in Angria's harbour could now catch him. He called to the Gujarati, who shouted an order to the Biluchis; the worn-out men on the benches ceased rowing, except four, who pulled a few strokes every now and again to prevent the two vessels from colliding. Desmond had thought at first of stopping the rowing altogether and running the grab alongside the gallivat; but that course, while safe enough in the still water of the harbour, would have its dangers in the open sea. So, lashing the helm of the grab, he dropped into a small boat which had been bumping throughout the night against the vessel's side, and in a few minutes was on board the gallivat.
  • 36. He first inquired after the men who had been wounded in the night. One had a broken arm, which no one on board knew how to set. The Babu had certainly a much discoloured nose, the contusion having been caused no doubt by a splinter of wood thrown up by the shot. Two or three of the rowers had slight bruises and abrasions, but none had been killed and none dangerously hurt. Then Desmond had a short and earnest talk with the Gujarati, who alone of the men had sufficient seamanship to make him of any value in deciding upon the next move. "What is to be done with the gallivat?" asked Desmond. "Scuttle her, sahib, and hoist sail on the grab." "But the rowers?" "Fasten them to the benches and let them drown. They could not help our enemies then, and it would make up for what you and I and all of us have suffered in Gheria." "No, I can't do that," said Desmond. "It must be as I say, sahib. There is nothing else to do. We have killed no one yet, except the sentinel on the parapet; I did that neatly, the sahib will agree; I would have a life for every lash of the whip upon my back." "No," said Desmond decisively, "I will not drown the men. We will take on board the grab three or four, who must be sailors; let us ask who will volunteer. We will promise them good pay; we haven't any money, to be sure, but the grab can be sold when we reach Bombay, and though we stole her I think everybody would admit that she is our lawful prize. I should think they'll be ready enough to volunteer, for they won't care to return to Gheria and face Angria's rage. At the same time we can't take more than three or four,
  • 37. because in the daylight they can now see how few we are, and they might take a fancy to recapture the grab. What do you think of that plan?" The Gujarati sullenly assented. He did not understand mercy to an enemy. "There is no need to pay them, sahib," he said. "You can promise pay; a promise is enough." Desmond was unwilling to start an argument and said nothing. Once in Bombay he could ensure that any pledges given would be strictly kept. As he expected, there was no difficulty in obtaining volunteers. Twice the number required offered their services. They had not found their work with the Pirate so easy and so well rewarded as to have any great objection to a change of masters. Moreover, they no doubt feared the reception they would get from Angria if they returned. And it appeared afterwards that during the night the Biluchis had recounted many fabulous incidents all tending to show that the sahib was a very important as well as a very ingenious Firangi, so that this reputation, coupled with an offer of good pay, overcame any scruples the men might retain. Among those who volunteered and whose services were accepted was the serang of Angria's gallivat. Unknown to Desmond, while he was holding this conversation with the Gujarati, the serang, crouching in apparent apathy on his bench, had really strained his ears to catch what was being said. He, with the three other men selected, was released from his bonds, and ordered to lower the long boat of the gallivat and stow in it all the ammunition for the guns that was to be found in the ship's magazine. This was then
  • 38. taken on board the grab, and Desmond ordered one of the Mysoreans to load the grab's stern chaser, telling the Marathas whom he intended to leave on the gallivat that, at the first sign of any attempt to pursue, their vessel would be sunk. Then in two parties the fugitives went on board the grab. Desmond was the last to leave the gallivat, releasing one of the captive rowers, who in his turn could release the rest. As soon as Desmond stepped on board the grab, the hawser connecting the two vessels was cast off, the mainsail was run up, and the grab, sailing large, stood up the coast. Fuzl Khan, swarming up to the mast-head, reported two or three sail far behind, apparently at the mouth of Gheria harbour. But Desmond, knowing that if they were in pursuit they had a long beat to windward before them, felt no anxiety on that score. Besides, the grab he was on had been selected precisely because it was the fastest vessel in Angria's fleet. Having got fairly under way, he felt that he had leisure to inspect the damage done to the grab by the shots from the fort which had given him so much concern in the darkness. That she had suffered no serious injury was clear from the ease with which she answered the helm and the rapidity of her sailing. He found that a hole or two had been made in the forepart of the deck, and a couple of yards of the bulwarks carried away. There was nothing to cause alarm or to demand instant repair. It was a bright cool morning, and Desmond, after the excitements and the strain of the last few days, felt an extraordinary lightness of spirit as the vessel cut through the water. For the first time in his life he knew the meaning of the word freedom; none but
  • 39. a man who has suffered captivity or duress can know such joy as now filled his soul. The long stress of his menial life on board the Good Intent, the weary months of toil, difficulty and danger as Angria's prisoner, were past; and it was with whole-hearted joyousness he realized that he was now on his way to Bombay, whence he might proceed to Madras, and Clive--Clive, the hero who was as a fixed star in his mental firmament. The gallivat, lying all but motionless on the water, a forlorn object with the jagged stump of her mainmast, grew smaller and smaller in the distance, and was soon hull down. Desmond, turning away from a last look in her direction, awoke from his reverie to the consciousness that he was ravenously hungry. CHAPTER THE FIFTEENTH In which our hero weathers a storm; and prepares for squalls. Hungry as he was, however, Desmond would not eat while he was, so to speak, still in touch with Gheria. He ran up the sail on the mizzen, and the grab was soon cutting her way through the water at a spanking rate. He had closely studied the chart on board the Good Intent when that vessel was approaching the Indian coast--not with any fixed purpose, but in the curiosity which invested all things Indian with interest for him. From his recollection he believed that Gheria was somewhat more than a hundred miles from Bombay. If
  • 40. the grab continued to make such good sailing, she might hope to cover this distance by midnight. But she could hardly run into harbour until the following day. There was of course no chart, not even a compass, on board; the only apparatus he possessed was a water-clock; naturally he could not venture far out to sea, but neither dared he hug the shore too closely. He knew not what reefs there might be lying in wait for his untaught keel. Besides, he might be sighted from one or other of the coast strongholds still remaining in Angria's hands, and it was not impossible that swift messengers had already been sent along the shore from Gheria, prescribing a keen look-out and the chase of any solitary grab making northward. But if he kept too far out he might run past Bombay, though when he mentioned this to his fellow-fugitives he was assured by the Biluchis and Fuzl Khan that they would unfailingly recognize the landmarks, having more than once in the course of their trading and pirate voyages touched at that port. On the whole he thought it best to keep the largest possible offing that would still leave the coast within sight. Putting the helm down he ran out some eight or ten miles, until the coast was visible only from the mast-head as a purple line on the horizon, with occasional glimpses of high ghats[#] behind. [#] Mountains. Meanwhile the Gujarati and some of the others had breakfasted from their bundles. Leaving the former in charge of the wheel, Desmond took his well-earned meal of rice and chapatis, stale, but sweet with the sweetness of freedom.
  • 41. In his ignorance of the coast he felt that he must not venture to run into Bombay in the darkness, and resolved to heave-to during the night. At the dawn he could creep in towards the shore without anxiety, for there was little chance of falling in with hostile vessels in the immediate neighbourhood of Bombay. Knowing that a considerable British fleet lay there, the Pirate would not allow his vessels to cruise far from his own strongholds. But as there was a prospect of spending at least one night at sea, it was necessary to establish some system of watches. The task of steering had to be shared between Desmond and Fuzl Khan; and the majority of the men being wholly inexperienced, it was not safe to leave fewer than six of them on duty at a time. The only danger likely to arise was from the weather. So far it was good; the sea was calm, the sky was clear; but Desmond was enough of a seaman to know that, being near the coast, the grab might at any moment, almost without warning, be struck by a squall. He had to consider how best to divide up his crew. Including himself there were eleven men on board. Four of them were strangers of whom he knew nothing; the six who had escaped with him were known only as fellow-prisoners. To minimize any risk, he divided the crew into three watches. One consisted of the Babu, the serang, and one of the Marathas from the gallivat. Each of the others comprised a Mysorean, a Biluchi, and a Maratha. Thus the strangers were separated as much as possible, and the number of Marathas on duty was never in excess of the number of fugitives; the steersman, Desmond or the Gujarati as the case might be, turned the balance.
  • 42. The watch was set by means of the water-clock found in the cabin. Desmond arranged that he and Fuzl Khan should take alternate periods of eight hours on and four off. The two matchlocks taken from the sentinels of the fort and brought on board were loaded and placed on deck near the wheel. None of the crew were armed save the Biluchis, who retained their knives. Towards midday the wind dropped almost to a dead calm. This was disappointing, for Desmond suspected that he was still within the area of Angria's piratical operations--if not from Gheria, at any rate from some of the more northerly strongholds not yet captured by the East India Company or the Peshwa. But he had a good offing: scanning the horizon all around he failed to sight a single sail; and he hoped that the breeze would freshen as suddenly as it had dropped. Now that excitement and suspense were over, and there was nothing that called for activity, Desmond felt the natural reaction from the strain he had undergone. By midday he was so tired and sleepy that he found himself beginning to doze at the wheel. The Gujarati had been sleeping for some hours, and as the vessel now required scarcely any attention, Desmond thought it a good opportunity for snatching a rest. Calling to Fuzl Khan to take his place, and bidding him keep the vessel's head, as far as he could, due north, he went below. About six bells, as time would have been reckoned on the Good Intent, he was wakened by the Babu, with a message from the Gujarati desiring him to come on deck. "Is anything wrong, Babu?" he asked, springing up. "Not so far as I am aware, sahib. Only it is much hotter since I began my watch."
  • 43. Desmond had hardly stepped on deck before he understood the reason of the summons. Overhead all was clear; but towards the land a dense bank of black cloud was rising, and approaching the vessel with great rapidity. It was as though some vast blanket were being thrown seawards. The air was oppressively hot, and the sea lay like lead. Desmond knew the signs; the Gujarati knew them too; and they set to work with a will to meet the storm. Fortunately Desmond, recognizing the unhandiness of his crew, had taken care to set no more sail than could be shortened at the briefest notice. He had not been called a moment too soon. A flash lit the black sky; a peal of thunder rattled like artillery far off; and then a squall struck the grab with terrific force, and the sea, suddenly lashed into fury, advanced like a cluster of green liquid mountains to overwhelm the vessel. She heeled bulwarks under, and was instantly wrapped in a dense mist, rain pouring in blinding sheets. The maintopsail was blown away with a report like a gun- shot; and then, under a reefed foresail, the grab ran before the wind, which was apparently blowing from the south-east. Furious seas broke over the deck; the wind shrieked through the rigging; the vessel staggered and plunged under the shocks of sea and wind. Fuzl Khan clung to the helm with all his strength, but his arms were almost torn from their sockets, and he called aloud for Desmond to come to his assistance. It was fortunate that little was required of the crew, for in a few minutes all of them save the four Marathas from the gallivat were prostrated with sea-sickness. The Babu had run below, and occasionally, between two gusts, Desmond could hear the shrieks and groans of the terrified man. But he had no time to sympathize;
  • 44. his whole energies were bent on preventing the grab from being pooped. He felt no alarm; indeed, the storm exhilarated him; danger is bracing to a courageous spirit, and his blood leapt to this contest with the elements. He thrilled with a sense of personal triumph as he realized that the grab was a magnificent sea-boat. There was no fear but that the hull would stand the strain; Desmond knew the pains that had been expended in her building: the careful selection of the timbers, the niceness with which the planks had been fitted. No European vessel could have proved her superior in seaworthiness. But she was fast drifting out into the Indian Ocean, far away from the haven Desmond desired to make. How long was this going to last? Whither was he being carried? Without chart or compass he could take no bearings, set no true course. It was a dismal prospect, and Desmond, glowing as he was with the excitement of the fight, yet felt some anxiety. Luckily, besides the provisions brought in their bundles by the fugitives, there was a fair supply of food and water on board; for although every portable article of value had been taken on shore when the grab anchored in Gheria, it had not been thought necessary to remove the bulkier articles. Thus, if at the worst the vessel were driven far out to sea, there was no danger of starvation even if she could not make port for several days. But Desmond hoped that things would not come to this pass. Towards nightfall, surely, the squall would blow itself out. Yet the wind appeared to be gaining rather than losing strength; hour after hour passed, and he still could not venture to quit the wheel. He was drenched through and through with the rain; his muscles ached with the stress; and he could barely manage to eat the food and water
  • 45. brought him staggeringly by the serang in the intervals of the wilder gusts. The storm had lasted for nearly ten hours before it showed signs of abatement. Another two hours passed before it was safe to leave the helm. The wind had by this time fallen to a steady breeze; the rain had ceased; the sky was clear and starlit; but the sea was still running high. At length the serang offered to steer while the others got a little rest; and entrusting the wheel to him, Desmond and Fuzl Khan threw themselves down as they were, on the deck near the wheel, and were soon fast asleep. At dawn Desmond awoke to find the grab labouring in a heavy sea, with just steering-way on. The wind had dropped to a light breeze. The Gujarati was soon up and relieved the serang at the wheel; the rest of the crew, haggard, melancholy objects, were set to work to make things ship-shape. Only the Babu remained below; he lay huddled in the cabin, bruised, prostrate, unable to realize that the bitterness of death was past, unable to believe that life had any further interest for him. Desmond's position was perplexing. Where was he? Perforce he had lost his bearings. He scanned the whole circumference of the horizon, and saw nothing but the vast dark ocean plain and its immense blue dome--never a yard of land, never a stitch of canvas. He had no means of ascertaining his latitude. During the twelve hours of the storm the grab had been driven at a furious rate; if the wind had blown all the time from the south-east, the quarter from which it had struck the vessel, she must now be at least fifty miles from the coast, possibly more, and north of Bombay. In the inky blackness of the night, amid the blinding rain, it had been impossible
  • 46. to read anything from the stars. All was uncertain, save the golden sheen of sunlight in the east. Desmond's only course was to put the vessel about and steer by the sun. She must thus come sooner or later in sight of the coast, and then one or other of the men on board might recognize a landmark--a hill, a promontory, a town. The danger was that they might make the coast in the neighbourhood of one of the Pirate's strongholds; but that must be risked. For the rest of the day there were light variable winds, such as, according to Fuzl Khan, might be expected at that season of the year. The north-east monsoon was already overdue. Its coming was usually heralded by fitful and uncertain winds, varied by such squalls or storms as they had just experienced. The sea moderated early in the morning, and became continually smoother until, as the sun went down, there was scarce a ripple on the surface. The wind meanwhile had gradually veered to the south-west, and later to the west, and the grab began to make more headway. But with the fall of night it dropped to a dead calm, a circumstance from which the Gujarati inferred that they were still a long way from the coast. When the stars appeared, however, and Desmond was able to get a better idea of the course to set, a slight breeze sprang up again from the west, and the grab crept along at a speed of perhaps four knots. It had been a lazy day on board. The crew had recovered from their sickness, but there was nothing for them to do, and as Orientals they were quite content to do nothing. Only the Babu remained off duty, in addition to the watch below. Desmond visited him, and persuaded him to take some food: but nothing would
  • 47. induce him to come on deck; the mere sight of the sea, he said, would externalize his interior. It was Desmond's trick at the wheel between eight and midnight. Gulam Mahomed was on the look-out; the rest of the crew were forward squatting on the deck in a circle round Fuzl Khan. Desmond, thinking of other things, heard dully, as from a great distance, the drone of the Gujarati's voice. He was talking more freely and continuously than was usual with him; ordinarily his manner was morose; he was a man of few words, and those not too carefully chosen. So prolonged was the monotonous murmur, however, that Desmond by and by found himself wondering what was the subject of his lengthy discourse; he even strained his ears to catch, if it might be, some fragments of it; but nothing came into distinctness out of the low-pitched drone. Occasionally it was broken by the voice of one of the others; now and again there was a brief interval of silence; then the Gujarati began again. Desmond's thoughts were once more diverted to his own strange fate. Little more than a year before, he had been a boy, with no more experience than was to be gained within the narrow circuit of a country farm. What a gamut of adventure he had run through since then! He smiled as he thought that none of the folks at Market Drayton would recognize, in the muscular, strapping, sun-tanned seaman, the slim boy of Wilcote Grange. His imagination had woven many a chain of incident, and set him in many a strange place; but never had it presented a picture of himself in command of as mixed a crew as was ever thrown together, navigating unknown waters without chart or compass, a fugitive from the chains of an Eastern despot. His quick fancy was busy even now. He felt that it was not
  • 48. for nothing he had been brought into his present plight; and at the back of his mind was the belief, founded on his strong wish and hope, that the magnetism of Clive's personality, which he had felt so strongly at Market Drayton, was still influencing his career. At midnight Fuzl Khan relieved him at the wheel, and he turned in. His sleep was troubled. It was a warm night--unusually warm for the time of year. There were swarms of cockroaches and rats on board; the cockroaches huge beasts, three times the size of those that overran the kitchen at home; the rats seeming as large as the rabbits he had been wont to shoot on the farm. They scurried about with their little restless noises, which usually would have had no power to break his sleep; but now they worried him. He scared them into silence for a moment by striking upon the floor; but the rustle and clipper-clapper immediately began again. After vain efforts to regain his sleep, he at length rose and went on deck. He did not move with intentional quietness, but he was barefoot, and his steps made no sound. It was a black night, a warm haze almost shutting out the stars. As he reached the deck he heard low murmurs from a point somewhere aft. He had no idea what the time was: Shaik Abdullah had the water-clock, with which he timed the watches; and Desmond's could not yet be due. Avoiding the spot where the conversation was in progress, he leant over the bulwarks, and gazed idly at the phosphorescent glow upon the water. Then he suddenly became aware that the sounds of talking came from near the wheel, and Fuzl Khan was among the talkers. What made the man so uncommonly talkative? Seemingly he was taking up the thread where it had been dropped earlier in the night; what was it about?
  • 49. Desmond asked himself the question without much interest, and was again allowing his thoughts to rove when he caught the word "sahib," and then the word "Firangi" somewhat loudly spoken. Immediately afterwards there was a low hiss from the Gujarati, as of one warning another to speak lower. The experiences of the past year had quickened Desmond's wits; with reason he had become more suspicious than of yore, and the necessity to be constantly on his guard had made him alert, alive to the least suggestion. Why had the speaker been hushed--and by Fuzl Khan? He remembered the ugly rumours, the veiled hints he had heard about the man in Gheria. If they were true, he had sold his comrades who trusted him. They might not be true; the man himself had always indignantly denied them. Desmond had nothing against him. So far he had acted loyally enough; but then he had nothing to gain by playing his fellow-fugitives false, and it was with this knowledge that Desmond had decided to make him privy to the escape. But now they were clear of Gheria. Fuzl Khan was free like the rest; he had no longer the same inducement to play straight if his interest seemed to him to clash with the general. Yet it was not easy to see how such a clashing could occur. Like the others he was lost at sea; until land was reached, at any rate, he could have no motive for opposition or mutiny. While these thoughts were passing through Desmond's mind he heard a man rise from the group aft and come forward. Instinctively he moved from the side of the vessel towards the mainmast, and as the man drew near Desmond stood so that the stout tree-trunk was between them. The man went rapidly towards the bows, and in a low tone hailed the look-out, whispering him a summons to join the
  • 50. Gujarati at the helm. The look-out, one of the Marathas, left his post; he came aft with the messenger, and, both passing on the same side of the vessel, Desmond by dodging round the mast escaped their notice. At the best, the action of Fuzl Khan was a dereliction of duty; at the worst!--Desmond could not put his suspicions into words. It was clear that something was afoot, and he resolved to find out what it was. Very cautiously he followed the two men. Bending low, and keeping under the shadow of the bulwarks, he crept to within a few feet of the almost invisible group. A friendly coil of rope near the taffrail gave him additional cover; but the night was so dark that he ran little risk of being perceived so long as the men remained stationary. He himself could barely see the tall form of the Gujarati dimly outlined against the sky. CHAPTER THE SIXTEENTH In which a mutiny is quelled in a minute; and our Babu proves himself a man of war. Crouching low, Desmond waited. When the Maratha joined the group Fuzl Khan addressed him directly in a low firm tone. "We are all agreed, Nanna," he said. "You are the only man wanting to our purpose. This is the fastest grab on the coast. I know a port where we can get arms and ammunition; with a few good
  • 51. men (and I know where they can be found), we can make a strong band, and grow rich upon our spoils." "But what about the sahib?" "Wah! We know what these Firangi are like--at least the Angrezi.[#] They have the heads of pigs; there is no moving them. It would be vain to ask the young sahib to join us; his mind is set on getting to Bombay and telling all his troubles to the Company. What a folly! And what an injustice to us! It would destroy our chance of making our fortunes, for what would happen? The grab would be sold; the sahib would take the most of the price; we should get a small share, not enough to help us to become rovers of the sea and our own masters." [#] English. "The sahib will refuse, then. So be it! But what then shall we do with him?" "He will not get the chance of refusing. He will not be told." "But he is taking us to Bombay. How then can we work our will?" "He thinks he is sailing to Bombay: he will really take us to Cutch." "How is that, brother?" "Does he know Bombay? Of a truth no. He is a boy: he has never sailed these seas. He depends on us. Suppose we come in sight of Bombay, who will tell him? Nobody. If he asks, we will say it is some other place: how can he tell? We will run past Bombay until we are within sight of Cutch: then truly I will do the rest."
  • 52. The Maratha did not reply. The momentary silence was broken by Fuzl Khan again. "See! Put the one thing in the balance against the other: how does it turn? On the one side the twenty rupees--a pitiful sum-- promised by the sahib: and who knows he will keep his promise? On the other, a tenth share for each of you in the grab and whatsoever prey falls to it." "Then the Babu is to have a share? Of a truth he is a small man, a hare in spirit; does he merit an equal share with us? We are elephants to him." "No. He will have no share. He will go overboard." "Why, then, what of the tenth share?" "It will be mine. I shall be your leader and take two." Desmond had heard enough. The Gujarati was showing himself in his true colours. His greed was roused, and the chance of setting up as a pirate on his own account, and making himself a copy of the man whose prisoner he had been, had prompted this pretty little scheme. Desmond crept noiselessly away and returned to his quarters. Not to sleep; he spent the remainder of his watch below in thinking out his position--in trying to devise some means of meeting this new and unexpected difficulty. He had not heard what Fuzl Khan proposed ultimately to do with him. He might share the Babu's fate: at the best it would appear that he had shaken off one captivity to fall into the toils of another. He had heard grim tales of the pirates of the Cambay Gulf; they were not likely to prove more pleasant masters than the Marathas farther south, even if they did not prefer to put him summarily out of the way. His presence among them might prove irksome, and what would the death of a single English
  • 53. youth matter? He was out of reach of all his friends; on the Good Intent none but Bulger and the New Englander had any real kindness for him, and if Bulger were to mention at any port that a young English lad was in captivity with the Pirate, what could be done? Should the projected expedition against Gheria prove successful, and he not be found among the European prisoners, it would be assumed that he was no longer living; and even if the news of his escape was known, it was absurd to suppose that all India would be searched for him. The outlook, from any point of view, was gloomy. The Gujarati had evidently won over the whole ship's company. Were they acting from the inclination for a rover's life, coupled with hope of gain, or had they been jockeyed into mutiny by Fuzl Khan? Desmond could not tell, nor could he find out without betraying a knowledge of the plot. Then he remembered the Babu. He alone had been excepted; the other men held him in contempt; but despite his weaknesses, for which he was indeed hardly accountable, Desmond had a real liking for him; and it was an unpleasant thought that, whatever happened to himself, if the plot succeeded Surendra Nath was doomed. But thinking of this, Desmond saw one ray of hope. He had not been for long the companion of men of different castes without picking up a few notions of what caste meant. The Babu was a Brahman; as a Bengali he had no claim on the sympathies of the others; but as a Brahman his person to other Hindus was inviolable. The Marathas were Hindus, and they at least would not willingly raise their hand against him. Yet Desmond could not be certain on this point. During his short residence in Gheria he had found that, in the East as too often in the West, the precepts of religion were apt
  • 54. to be kept rather in the letter than in the spirit. He had seen the sacred cow, which no good Hindu would venture to kill for untold gold, atrociously overworked, and, when too decrepit to be of further service, left to perish miserably of neglect and starvation. It might be that although the Marathas would not themselves lay hands on the Babu, they would be quite content to look calmly on while a Mohammedan did the work. At the best, it was Desmond and the Babu against the crew-- hopeless odds, for if it came to a fight the latter would be worse than useless. Not that Desmond held the man in such scorn as the men of his own colour. Surendra Nath was certainly timid and slack, physically weak, temperamentally a coward: yet he had shown gleams of spirit during the escape, and it seemed to Desmond that he was a man who, having once been induced to enter upon a course, might prove both constant and loyal. The difficulty now was that, prostrated by his illness during the storm, he was not at his best; certainly in no condition to face a difficulty either mental or physical. So Desmond resolved not to tell him of the danger impending. He feared the effect upon his shaken nerves. He would not intentionally do anything against Desmond's interest, but he could scarcely fail to betray his anxiety to the conspirators. Feeling that there was nobody to confide in, Desmond decided that his only course was to feign ignorance of what was going on, and await events with what composure he might. Not that he would relax his watchfulness; on the contrary he was alert and keen, ready to seize with manful grip the skirts of chance. Perhaps, he thought, the grab might fall in with a British ship. But what would that avail? The grab with her extraordinary sailing
  • 55. powers could show a clean pair of heels to any Indiaman, however fast, even if he could find an opportunity of signalling for help. Fuzl Khan, without doubt, would take care that he never had such a chance. Turning things over in his mind, and seeing no way out of his difficulty, he was at length summoned to relieve the Gujarati at the wheel. It was, he supposed, about four in the morning, and still pitch-dark. When he came to the helm Fuzl Khan was alone: there was nothing to betray the fact that the plotters had, but little before, been gathered around him. The look-out, who had left his post to join the group, had returned forward, and was now being relieved, like the Gujarati himself. Desmond exchanged a word or two with the man, and was left alone at the wheel. His mind was still set on the problem how to frustrate the scheme of the mutineers. He was convinced that if the grab once touched shore at any point save Bombay, his plight would be hopeless. But how could he guard against the danger? Even if he could keep the navigation of the grab entirely in his own hands by remaining continuously at the helm, he was dependent on the plotters for information about the coast; to mislead him would be the easiest thing in the world. But it suddenly occurred to him that he might gain time by altering the course of the vessel. If he kept out of sight of land he might increase the chance of some diversion occurring. Accordingly he so contrived that the grab lost rather than gained in her tacks against the light north-west wind now blowing. None of the men, except possibly the Gujarati, had sufficient seamanship to detect this manoeuvre; he had gone below, and
  • 56. when he came on deck again he could not tell what progress had been made during his absence. Only the mainsail, foresail, and one topsail were set: these were quite enough for the untrained crew to trim in the darkness--likely to prove too much, indeed, in the event of a sudden squall. Thus the process of going about was a long and laborious one, and at the best much way was lost. Not long after he had begun to act on this idea he was somewhat concerned to see the serang, who was in charge of the deck watch, come aft and hang about near the wheel, as though his curiosity had been aroused. Had he any suspicions? Desmond resolved to address the man and see what he could infer from the manner of his reply. "Is all well, serang?" "All well, sahib," answered the man. He stopped, and seemed to hesitate whether to say more; but after a moment or two he moved slowly away. Desmond watched him. Had he discovered the trick? Would he go below and waken Fuzl Khan? Desmond could not still a momentary tremor. But the serang did not rejoin his messmates, nor go below. He walked up and down the deck alone. Apparently he suspected nothing. Desmond felt relieved; but though he was gaining time, he could but recognize that it seemed likely to profit him little. A criminal going to execution may step never so slowly across the prison yard; there is the inexorable gallows at the end, and certain doom. Could he not force matters, Desmond wondered? It was evidently to be a contest, whether of wits or of physical strength, between himself and the Gujarati. Without one or other the vessel could not be safely navigated; if he could in some way overcome the
  • 57. ringleader, he felt pretty sure that the crew would accept the result and all difficulty would be at an end. But how could he gain so unmistakable an ascendency? In physical strength Fuzl Khan was more than his match: there was no doubt of the issue of a struggle if it were a matter of sheer muscular power. For a moment he thought of attempting to enlist the Marathas on his side. They were Hindus; the Gujarati was a Muslim; and they must surely feel that, once he was among his co-religionists in Cutch, in some pirate stronghold, they would run a very poor chance of getting fair treatment. But he soon dismissed the idea. The Gujarati must seem to them much more formidable than the stripling against whom he was plotting. The Hindu, even more than the average human being elsewhere, is inclined to attach importance to might and bulk--even to mere fat. If he sounded the Marathas, and, their fear of the Gujarati outweighing their inevitable distrust of him as a Firangi, they betrayed him to curry a little favour, there was no doubt that the fate both of himself and the Babu would instantly be decided. He must trust to himself alone. While he was still anxiously debating the matter with himself his eye caught the two muskets lashed to the wooden framework supporting the wheel. He must leave no hostages to fortune. Taking advantage of a lull in the wind he steadied the wheel with his body, and with some difficulty drew the charges and dropped them into the sea. If it came to a tussle the enemy would certainly seize the muskets; it would be worth something to Desmond to know that they were not loaded. It was, in truth, but a slight lessening of the odds against him; and as he restored the weapons to their place he felt once more how hopeless his position remained.
  • 58. 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! ebookname.com