0% found this document useful (0 votes)
47 views86 pages

Murach S Java Servlets and JSP 3rd Edition Edition Joel Murach Download

The document provides information on the 3rd edition of 'Murach's Java Servlets and JSP' by Joel Murach and Michael Urban, which covers essential skills for developing web applications using Java. It includes chapters on web application structure, servlets, JSP, session management, and database integration, along with practical examples and exercises. The document also lists additional Murach titles for various programming languages and technologies.

Uploaded by

doditbuqee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views86 pages

Murach S Java Servlets and JSP 3rd Edition Edition Joel Murach Download

The document provides information on the 3rd edition of 'Murach's Java Servlets and JSP' by Joel Murach and Michael Urban, which covers essential skills for developing web applications using Java. It includes chapters on web application structure, servlets, JSP, session management, and database integration, along with practical examples and exercises. The document also lists additional Murach titles for various programming languages and technologies.

Uploaded by

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

Murach s Java Servlets and JSP 3rd Edition

Edition Joel Murach pdf download

https://ebookgate.com/product/murach-s-java-servlets-and-jsp-3rd-
edition-edition-joel-murach/

Get Instant Ebook Downloads – Browse at https://ebookgate.com


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

Murach s Java SE 6 1st Ed. Edition Joel Murach

https://ebookgate.com/product/murach-s-java-se-6-1st-ed-edition-joel-
murach/

ebookgate.com

Murach s C 2010 4th Edition Joel Murach

https://ebookgate.com/product/murach-s-c-2010-4th-edition-joel-murach/

ebookgate.com

Murach s HTML5 and CSS3 3rd Edition Anne Boehm

https://ebookgate.com/product/murach-s-html5-and-css3-3rd-edition-
anne-boehm/

ebookgate.com

Murach s JavaScript 2nd Edition Mary Delamater

https://ebookgate.com/product/murach-s-javascript-2nd-edition-mary-
delamater/

ebookgate.com
Murach s HTML5 and CSS3 1st Edition Zak Ruvalcaba

https://ebookgate.com/product/murach-s-html5-and-css3-1st-edition-zak-
ruvalcaba/

ebookgate.com

Murach s SQL Server 2012 for Developers 1st Edition Bryan


Syverson

https://ebookgate.com/product/murach-s-sql-server-2012-for-
developers-1st-edition-bryan-syverson/

ebookgate.com

Developing Java Servlets 2nd Edition James Goodwill

https://ebookgate.com/product/developing-java-servlets-2nd-edition-
james-goodwill/

ebookgate.com

Murach s ADO NET 4 Database Programming with VB 2010 4th


Edition Anne Boehm

https://ebookgate.com/product/murach-s-ado-net-4-database-programming-
with-vb-2010-4th-edition-anne-boehm/

ebookgate.com

Murach s ASP NET 4 Web Programming with VB 2010 4th


Edition Anne Boehm

https://ebookgate.com/product/murach-s-asp-net-4-web-programming-with-
vb-2010-4th-edition-anne-boehm/

ebookgate.com
I

3RD EDITION
TRAINING & REFERENCE

3RD EDITION

Joel Murach
Michael Urban

MIKE MURACH & ASSOCIATES, INC.


4340 N. Knoll Ave. • Fresno, CA 93722
www.murach.com • [email protected]
Authors: Joel Murach
Michael Urban
Editor: Ray Halliday
Production: Maria Spera

Books for Java programmers


Murach's Java Programming
Murach's Android Programming
Murach's Java Servlets and ISP (Jrd Edition)

Books for web developers


Murach's HTML5 and CSS3
Murach's Dreamweaver CC
Murach's JavaScript andjQuery
Murach's JavaScript and DOM Scripting
Murach's PHP and MySQL

Books for .NET programmers


Murach's C# 2012
Murach's ASP.NET 4.5 Web Programming with C# 2012
Murach's Visual Basic 2012
Murach's ASP.NET 4.5 Web Programming with VB 2012

Books for database developers


Murach's MySQL
Murach's Oracle SQL and PL!SQL
Murach's SQL Server 2012 for Developers

Books for IBM mainframe programmers


Murach's OS/390 and z/OS JCL
Murach's Mainframe COBOL
Murach's CfCS for the COBOL Programmer

Please check www.murach.com


for the most up-to-date Murach books

© 2014, Mike Murach & Associates, Inc.


All rights reserved.
Printed in the United States of America

10 9 8 7 6 5 4 3 2 1
ISBN-13: 978-1-890774-78-3
Content
Introduction

Section 1 Get started right


Chapter 1 An introduction to web programming with Java 3
Chapter 2 How to structure a web application with the MVC pattern 29
Chapter 3 How to use NetBeans and Tomcat 49

Section 2 Essential servlet and JSP skills


Chapter 4 A crash course in HTML5 and CSS3 89
Chapter 5 How to develop serv lets 127
Chapter 6 How to develop JavaServer Pages 173
Chapter 7 How to work with sessions and cookies 201
Chapter 8 How to use EL 243
Chapter 9 How to use JSTL 269
Chapter 10 How to use custom JSP tags 307

Section 3 Essential database skills


Chapter 11 How to use a MySQL database 347
Chapter 12 How to use JDBC to work with a database 377
Chapter 13 How to use JPA to work with a database 421

Section 4 Advanced servlet and JSP skills


Chapter 14 How to use JavaMail to send email 459
Chapter 15 How to use SSL to work with a secure connection 483
Chapter 16 How to restrict access to a web resource 501
Chapter 17 More security skills 525
Chapter 18 How to work with HTTP requests and responses 543
Chapter 19 How to work with listeners 571
Chapter 20 How to work with filters 587
Chapter 21 How to work with JavaServer Faces 613

Section 5 The Music Store website


Chapter 22 An introduction to the Music Store website 643
Chapter 23 The applications of the website 673

Appendixes
Appendix A How to set up your PC for this book 691
Appendix B How to set up your Mac for this book 711
••
Expanded contents VI I

Expanded contents
Section 1 Get started right
Chapter 1 An introduction to web applications
A typical web application ............................................................................................... 4
The components of a web application ............................................................................ 6
How static web pages work .............................................................................................8
How dynamic web pages work ..................................................................................... 10
Three approaches for Java web applications ................................ 12
Servlet/JSP .................................................................................................................... 12
JSF ................................................................................................................................. 12
Spring Framework ........................................................................................................ 12
An introduction to servlet/JSP web development ........................ 14
The software components ............................................................................................. 14
The architecture ............................................................................................................ 16
The standard directories and files ................................................................................. 18
Software for developing Java web applications ............................20
IDEs for developing Java web applications .................................................................. 20
Web servers for Java web applications ......................................................................... 22
Database servers for Java web applications .................................................................. 22
Tools for deploying Java web applications ................................................................... 24

Chapter 2 How to structure a web application


with the MVC patt'ern
Two patterns for servlet/JSP applications ..................................... 30
The Model 1 pattern ...................................................................................................... 30
The Model 2 (MVC) pattern ......................................................................................... 32
A servlet/JSP application that uses the MVC pattern ................... 34
The user interface ......................................................................................................... 34
The HTML for the first page ........................................................................................ 36
The CSS for both web pages ......................................................................................... 38
The servlet for the back-end processing ....................................................................... 40
The web.xml file ........................................................................................................... 42
The User class ............................................................................................................... 44
The JSP for the second page .........................................................................................46

Chapter 3 How to use NetBeans and Tomcat


How to get started with NetBeans .................................................. 50
How to start NetBeans .................................................................................................. 50
How to create a new web application ........................................................................... 52
How to use the Projects window ................................................................................... 56
How to open and close projects .................................................................................... 58
How to build , deploy, and run a web application ......................................................... 60
How to work with HTML and JSP files ............................................ 62
How to add an HTML or JSP' file ................................................................................. 62
How to edit an HTML or JSP file .................................................................................64
•••
VI 11 Expanded contents

How to work with Java files ............................................................. 66


How to add a Java class ................................................................................................. 66
How to add a servlet...................................................................................................... 68
How to edit a Java file ................................................................................................... 70
How to work with XML files .............................................................. 72
How to edit the web.xml file......................................................................................... 72
How to edit other XML files ......................................................................................... 72
Other skills for working with web applications ............................. 74
How to add existing files to a project............................................................................ 74
How to deploy a web application to a remote server .................................................... 74
How to work with a web application server .................................................................. 76
How to add a class library or a JAR file to a project .................................................... 78
How to register a database connection ......................................................................... 80

Section 2 Essential servlet and JSP skills


Chapter 4 A crash course in HTMLS and CSS3
How to work with HTML ................................................................... 90
The starting HTML for a web page.............................................................................. 90
How to code HTML elements ...................................................................................... 92
How to use the HTML5 semantic elements ................................................................. 94
How to use the div and span elements with HTML5 ................................................... 96
How to ensure cross-browser compatibility ................................................................. 98
How to code links ....................................................................................................... 100
How to include images ................................................................................................ 102
How to code tables ...................................................................................................... 104
How to work with CSS .................................................................... 106
How to provideCSS styles for an HTML page .......................................................... 106
How to code the basic CSS selectors .......................................................................... 108
How to codeCSS rule sets and com ments ................................................................. 110
How to useCSS to format a table ............................................................................... 112
How to code HTML forms ............................................................... 114
How to code a form ..................................................................................................... 114
How to code text boxes ............................................................................................... 116
How to code buttons ................................................................................................... 118
How to code check boxes and radio buttons............................................................... 120
How to code combo boxes and list boxes ................................................................... 122

Chapter 5 How to develop servlets


How to create and map a servlet ................................................... 128
How to create a servlet ................................................................................................ 128
How to map a servlet with the web.xml file ............................................................... 130
How to map a servlet with an annotation ................................................................... 132
How to request a servlet ................................................................ 134
How to use the HTTP GET method ........................................................................... 134
How to use the HTTP POST method ......................................................................... 136
When to use the HTTP GET and POST methods ...................................................... 136
Skills for working with servlets ..................................................... 138
How to get the values of the parameters..................................................................... 138
How to get the real path for a file ............................................................................... 140
Expanded contents IX

How to get and set request attributes .......................................................................... 142


How to forward requests ............................................................................................. 144
How to redirect responses........................................................................................... 144
How to validate data ....................................................................... 146
How to validate data on the client .............................................................................. 146
How to validate data on the server ............................................................................. 146
How to work with the web.xml file ................................................. 150
A complete web.xml file ............................................................................................. 150
How to work with initialization parameters ............................................................... 152
How to implement custom error handling .................................................................. 156
More skills for working with servlets ............................................ 160
How the methods of a servlet work ............................................................................ 160
Why you shouldn't use instance variables in servlets ................................................ 162
How to work with servlet errors .................................................... 164
How to solve common servlet problems ..................................................................... 164
How to print debugging data to the console ............................................................... 166
How to print debugging data to a log file ................................................................... 168

Chapter 6 How to develop JavaServer Pages


A crash course in EL and JSTL ..................................................... 174
How to code a JavaBean ............................................................................................. 174
How to use EL to get attributes and JavaBean properties .......................................... 176
How to enable the core JSTL library .......................................................................... 178
How to use the JSTL if tag ......................................................................................... 178
How to use JSP tags ....................................................................... 180
How to code directives, scriptlets, and expressions ................................................... 180
How to code comments in a JSP ................................................................................. 182
How to use standard JSP tags with Java Beans .......................... 184
An introduction to standard JSP tags ......................................................................... 184
How to code the useBean tag ...................................................................................... 186
How to code the getProperty and setProperty tags .................................................... 188
How to include a file in a JSP ........................................................ 190
A JSP that includes a header and footer file ............................................................... 190
Three techniques for including files in a JSP ............................................................. 194
How to fix common JSP errors...................................................... 196
Chapter 7 How to work with sessions and cookies
An introduction to session tracking .............................................202
Why session tracking is difficult with HTTP ............................................................. 202
How session tracking works in Java ...........................................................................202
An application that needs session tracking.................................................................204
How to work with sessions ............................................................206
How to set and get session attributes .......................................................................... 206
More methods of the session object. ........................................................................... 208
How to provide thread-safe access to the session object............................................ 210
How to work with cookies .............................................................. 212
An introduction to cookies ......................................................................................... 212
How to create and use cookies.................................................................................... 214
How to view and delete cookies ................................................................................. 216
X Expanded contents

Four methods for working with cookies ..................................................................... 218


A utility class for working with cookies ..................................................................... 220
How to work with URL rewriting and hidden fields ..................... 222
How to use URL rewriting to pass parameters .......................................................... 222
How to use hidden fields to pass parameters .............................................................. 224
The Download application ............................................................. 226
The user interface ....................................................................................................... 226
The file structure ......................................................................................................... 228
The web.xml file ......................................................................................................... 228
The code for the JSPs .................................................................................................. 230
The code for the servlet .............................................................................................. 234

Chapter 8 How to use EL


An introduction to JSP Expression Language ............................ 244
Advantages of EL........................................................................................................244
Disadvantages of EL ...................................................................................................244
Essential skills for working with EL.............................................. 246
How to use the dot operator to work with JavaBeans and maps ................................246
How to use EL to specify scope ................................................................................. 248
How to use the [ ] operator to work with arrays and lists ........................................... 250
How to use the dot operator to access nested properties ............................................ 252
Other skills for working with EL .................................................... 254
How to use the [ ] operator to access attributes .......................................................... 254
How to work with the other implicit EL objects ........................................................ 256
How to work with other EL operators ........................................................................ 260
How to disable EL....................................................................................................... 264
How to disable scripting ............................................................................................. 264

Chapter 9 How to use JSTL


An introduction to JSTL ................................................................. 270
The JSTL libraries ...................................................................................................... 270
How to make the JSTL JAR files available to your application ................................. 270
How to code the taglib directive ................................................................................. 270
How to code a JSTL tag .............................................................................................. 270
How to view the documentation for a library ............................................................. 272
How to work with the JSTL core library ....................................... 274
How to use the out tag ................................................................................................. 274
How to use the for Each tag ......................................................................................... 276
How to use the forTokens tag ...................................................................................... 278
Four more attributes for looping ................................................................................. 280
How to use the if tag ................................................................................................... 282
How to use the choose tag .......................................................................................... 284
How to use the url tag ................................................................................................. 286
Other tags in the JSTL core library ............................................................................ 288
The Cart application ....................................................................... 290
The user interface ....................................................................................................... 290
The code for the business classes ............................................................................... 292
The code for the servlets and JSPs .............................................................................. 296
Expanded contents XI

Chapter 10 How to use custom JSP tags


How to code a custom tag that doesn't have a body .................. 308
The tag ........................................................................................................................ 308
The tag element ........................................................................................................... 310
The tag class................................................................................................................ 312
How to code a custom tag that has a body .................................. 314
The tag ........................................................................................................................ 314
The tag element ........................................................................................................... 316
The tag class................................................................................................................ 316
How to code a custom tag that has attributes ............................. 318
The tag ........................................................................................................................ 318
The tag element ........................................................................................................... 320
The tag class................................................................................................................ 322
How to code a custom tag that reiterates its body ..................... 324
The tag ........................................................................................................................ 324
The tag element ........................................................................................................... 326
The tag class................................................................................................................ 326
How to work with scripting variables............................................330
An introduction to scripting variables ........................................................................ 330
The TEI class for four scripting variables .................................................................. 332
Classes, methods, and fields for working with custom tags ..... 334
Methods and fields of the Tag Support class ............................................................... 334
Methods and fields of the PageContext class.............................................................. 336
Methods and fields of the BodyTagSupport class ....................................................... 338
Methods and fields of the BodyContent class............................................................. 340

Section 3 Essential database skills


Chapter 11 How to use a MySQL database
An introduction to MySQL .............................................................348
What MySQL provides ............................................................................................... 348
Two ways to interact with MySQL ............................................................................. 350
How to use MySQL Workbench ..................................................... 352
The Home tab of MySQL Workbench ........................................................................ 352
How to open a database connection............................................................................ 354
How to start and stop the MySQL ser ver ................................................................... 356
How to enter and execute a SQL statement ................................................................ 358
How to enter and execute a SQL script....................................................................... 360
The SQL statements for creating a database ..............................362
How to create, select, and drop a database ................................................................. 362
How to create and drop a table ................................................................................... 364
How to insert multiple rows into a table ..................................................................... 366
The SQL statements for data manipulation ................................. 368
How to select data from a single table ........................................................................ 368
How to select data from multiple tables ..................................................................... 370
How to insert, update, and delete data........................................................................ 372
••
XI I Expanded contents

Chapter 12 How to use JDBC to work with a database


How to work with JDBC .................................................................. 378
An introduction to database drivers ............................................................................ 378
How to connect to a database ..................................................................................... 380
How to return a result set and move the cursor through it ......................................... 382
How to retrieve data from a result set. ........................................................................ 384
How to insert, update, and delete data ........................................................................ 386
How to work with prepared statements ...................................................................... 388
The SQL Gateway application .......................................................390
The user interface ....................................................................................................... 390
The code for the JSP ................................................................................................... 392
The code for the servlet .............................................................................................. 394
The code for the utility class ....................................................................................... 398
How to work with connection pooling .......................................... 400
How connection pooling works .................................................................................. 400
How to make a connection pool available .................................................................. 400
How to implement a connection pool .........................................................................402
How to use a connection pool .....................................................................................404
The Email List application .............................................................406
The user interface .......................................................................................................406
The code for the JSP ...................................................................................................406
The code for the servlet .............................................................................................. 408
The code for the database class .................................................................................. 410
The code for the utility class ....................................................................................... 416

Chapter 13 How to use JPA to work with a database


An introduction to JPA ................................................................... 422
A summary of JPA implementations .......................................................................... 422
Entities and the entity manager .................................................................................. 422
How to configure NetBeans to work with JPA ........................................................... 424
How to configure a persistence unit. ........................................................................... 426
How to code JPA entities ............................................................... 428
How to code the class for an entity .. ........................................................................... 428
How to use getter and field annotations ...................................................................... 430
How to code relationships between entities ................................................................ 432
How to work with dates and times .............................................................................. 434
How to retrieve data........................................................................ 436
How to get an entity manager factory ......................................................................... 436
How to retrieve an entity by primary key ................................................................... 438
How to retrieve multiple entities ................................................................................. 440
How to retrieve a single entity .................................................................................... 442
How to modify data ......................................................................... 444
How to insert, update, or delete a single entity ..........................................................444
How to update or delete multiple entities ...................................................................446
A complete JPA class.....................................................................448
The methods that modify data ....................................................................................448
The methods that retrieve data ................................................................................... 450
•••
Expanded contents XIII

Section 4 Advanced servlet and JSP skills


Chapter 14 How to use JavaMail to send mail
An introduction to the JavaMail API ............................................. 460
How email works ........................................................................................................460
How to install the JavaMail APL................................................................................ 462
Code that uses the JavaMail API to send an email message ...................................... 464
How to create and send an email message ................................. 466
How to create a mail session ....................................................................................... 466
How to create a message ............................................................................................. 468
How to address a message .......................................................................................... 470
How to send a message ............................................................................................... 472
Example classes that send an email message ............................ 474
A helper class for sending an email with a local SMTP server.................................. 474
A servlet that uses a helper class to send an email message ...................................... 476
A helper class for sending an email with a remote SMTP server .............................. 480

Chapter 15 How to use SSL to work with a secure connection


An introduction to SSL ................................................................... 484
How SSL works........................................................................................................... 484
How TLS works .......................................................................................................... 484
When to use a secure connection................................................................................ 484
How SSL authentication works................................................................................... 486
How to get a digital secure certificate ........................................................................ 488
How to configure a testing environment for SSL ........................ 490
How to create a certificate for testing ......................................................................... 490
How to enable SSL in Tomcat..................................................................................... 492
How to test a local SSL connection ............................................................................ 492
How to work with a secure connection ........................................ 494
How to request a secure connection ........................................................................... 494
A JSP that uses a secure connection ........................................................................... 496
How to return to a regular HTTP connection ............................................................ 496
How to switch from a local system to an Internet server ........................................... 496

Chapter 16 How to restrict access to a web resource


An introduction to authentication ................................................. 502
How container-managed authentication works........................................................... 502
T hree types of authentication ..................................................................................... 504
How to restrict access to web resources ..................................... 506
How to add a security role .......................................................................................... 506
How to add a security constraint ................................................................................ 506
How to implement a security realm .............................................. 508
How to implement the UserDatabaseRealm ............................................................... 508
How to implement the JDBCRealm ........................................................................... 510
How to implement the DataSourceRealm .................................................................. 514
How to allow access to authorized users ..................................... 516
How to use basic authentication.................................................................................. 516
How to use digest authentication ................................................................................ 516
How to use form-based authentication ....................................................................... 518
XIV Expanded contents

Chapter 17 More security skills


An introduction to website security.............................................. 526
Common website attacks ............................................................................................ 526
How to prevent social engineering attacks ................................................................. 526
An introduction to cryptography ................................................................................ 528
Common password attacks ......................................................................................... 530
How to protect passwords ............................................................. 532
How to hash passwords ............................................................................................... 532
How to salt passwords ................................................................................................. 534
A utility class for hashing and salting passwords ....................................................... 536
How to enforce password strength requirements ....................................................... 538

Chapter 18 How to work with HTTP requests and responses


An introduction to HTTP ................................................................ 544
An HTTP request and response .................................................................................. 544
Common MIME types ................................................................................................ 546
Common HTTP request headers ................................................................................ 548
Common HTTP status codes ...................................................................................... 550
Common HTTP response headers .............................................................................. 552
How to work with the request ........................................................ 554
How to get a request header ........................................................................................ 554
How to display all request headers ............................................................................. 556
How to work with the response ..................................................... 558
How to set status codes ............................................................................................... 558
How to set response headers ....................................................................................... 558
Practical HTTP skills ...................................................................... 560
How to return a spreadsheet ....................................................................................... 560
How to control caching ............................................................................................... 560
How to compress a response with GZIP..................................................................... 562
How to return a binary file as an attachment ............................................................. 564
How to create virtual HTML pages............................................................................ 566

Chapter 19 How to work with listeners


How to use a ServletContextlistener ........................................... 572
How to code a class for the listener ............................................................................ 572
How to register the listener ......................................................................................... 574
How to code a JSP that uses the attributes set by the listener .................................... 576
How to work with other types of listeners.................................... 578
A summary of the listener interfaces ......................................................................... 578
The methods of the listener interfaces ........................................................................ 580
The methods of the event objects ............................................................................... 582

Chapter 20 How to work with fliters


An introduction to filters ................................................................ 588
How filters work .......................................................................................................... 588
Two benefits of filters .................................................................................................. 588
When to use filters ...................................................................................................... 588
How to add a filter ........................................................................... 590
How to code a filter ..................................................................................................... 590
How to configure a filter ............................................................................................. 592
Expanded contents XV

Two filter classes ............................................................................ 596


How to code a filter that performs request-side processing ....................................... 596
How to code a filter that performs response-side processing ..................................... 598
Other skills for workin,g with filters............................................... 600
How to wrap a request or response ............................................................................. 600
How to use an initialization parameter ....................................................................... 604
How to restrict access by IP address .......................................................................... 606

Chapter 21 How to work with JavaServer Faces


An introduction to JSF ................................................................... 614
A summary of JSF versions ........................................................................................ 614
How to add a JSF library to a project ......................................................................... 614
How to used managed beans ........................................................ 616
How to create a managed bean ................................................................................... 616
How to set the scope of a bean ................................................................................... 618
How to use standard JSF tags ...................................................... 620
How to code the head and body tags .......................................................................... 620
How to display data from a managed bean................................................................. 622
How to code the inputText tag .................................................................................... 624
How to validate data ................................................................................................... 626
How to code a form action .......................................................................................... 628
The Email List application ............................................................. 630
The user interface ....................................................................................................... 630
The EmailList bean..................................................................................................... 632
The index.xhtml file .................................................................................................... 634
The thanks.xhtml file .................................................................................................. 636

Section 5 The Music Store website


Chapter 22 An introduction to the Music Store website
The user interface ........................................................................... 644
The Home and Catalog pages ..................................................................................... 644
The code for the Home page ....................................................................................... 644
The business layer .......................................................................... 648
The class diagrams ...................................................................................................... 648
The Product class ........................................................................................................ 648
The controller layer......................................................................... 652
The CatalogController class ....................................................................................... 652
The structure ................................................................................... 656
The directory structure ............................................................................................... 656
The web.xml file ......................................................................................................... 658
The context.xml file .................................................................................................... 658
The database ................................................................................... 662
The database diagram ................................................................................................. 662
The SQL script for the database ................................................................................. 662
The data layer .................................................................................. 666
The class diagrams...................................................................................................... 666
The ProductDB class .................................................................................................. 666
XVI Expanded contents

The JPA version compared to the JDBC version ........................ 670


The similarities ........................................................................................................... 670
The differences ........................................................................................................... 670

Chapter 23 The applications of the website


The user interface for end users ................................................... 674
The Download application.......................................................................................... 674
The Cart application ................................................................................................... 674
The user interface for administrators ........................................... 680
The Ad min Login page ............................................................................................... 680
The Ad min Menu page ............................................................................................... 682
The Process Invoices application................................................................................ 684
The Reports application .............................................................................................. 684

Appendix A How to set up your PC for this book


How to install the source code for this book .............................................................. 692
How to install the JDK ............................................................................................... 694
How to install NetBeans ............................................................................................. 696
How to install Tomcat ................................................................................................. 698
How to configure a Tomcat server .............................................................................. 700
How to test NetBeans and Tomcat .............................................................................. 704
How to install MySQL ................................................................................................ 706
How to create the databases for this book .................................................................. 708
How to restore the databases for this book................................................................. 708

Appendix B How to set up your Mac for this book


How to install the source code for this book .............................................................. 712
How to install the JDK ............................................................................................... 714
How to install NetBeans ............................................................................................. 716
How to install Tomcat ................................................................................................. 718
How to configure a Tomcat server .............................................................................. 720
How to test NetBeans and Tomcat .............................................................................. 724
How to install the MySQL Community Server .......................................................... 726
How to install MySQL Workbench ............................................................................ 728
How to create the databases for this book .................................................................. 730
How to restore the databases for this book................................................................. 730
How to update the password for the root user ............................................................ 732
Introduction
Java servlets and JavaServer Pages (JSPs) came into widespread use in the
late 1990s. For many years, servlets and JSPs were the dominant technology for
building web applications, especially for large enterprises. Although servlets and
JSPs are no longer the dominant approach to web programming, they have some
advantages over other newer approaches. In addition, since there are still many
legacy web applications powered by them, servlets and JSPs will continue to be
relevant for many years to come.
A quick search on a typical job website shows that there is still plenty
of demand for servlet and JSP developers. In addition, many of the skills for
working with servlets and JSPs also apply to newer approaches to Java web
development such as JavaServer Faces (JSF). As a result, learning servlets and
JSPs is still a great way to get started with Java web programming.

Who this book is for


This book is for anyone who wants to learn how to develop web applications
using servlets and JSP. The only prerequisite is a basic understanding of the Java
programming language roughly equivalent to chapters 1 through 14 of our core
Java book, Murach's Java Programming. Once you have the necessary Java
skills, this book should work for you even if you have no experience developing
web applications.

Why you'll learn faster and better with this book


When we started writing this book, we knew we had to take a new approach
if we wanted to teach you everything you need to know in a way that's faster and
better than the other books. Here, then, are a few of the ways in which our book
differs from the others:
• Chapter 2 shows how to use the MVC pattern (or Model 2 architecture) to
get the most from JSPs and servlets. This allows you to use servlets when
they're appropriate and JSPs when they're appropriate. As a result, you
won't waste your time learning how to use servlets for tasks that should be
handled by JSPs, or vice versa.
•••
XVI 11 Introduction

• Chapter 3 shows how to use the NetBeans IDE with a Tomcat server to
develop web applications on your own computer. By using this IDE, you'll
learn faster and better than you would without one. In contrast, most
competing books leave you to figure this out on your own.
• Chapter 4 of this book provides a crash course in HTML5 and CSS3. Since
this is essential background for the use of JSPs, this means you won't have
to use a second book to figure out how HTML and CSS work.
• This book includes dozens of examples that range from the simple to
the complex. That way, you can quickly see how a feature works from
the simple examples, but you'll also see how the feature is used in more
complex, real-world examples, including the complete e-commerce
application that's presented in section 5.
• At the end of most chapters, you'll find exercises that help you practice what
you've learned. They also encourage you to experiment and challenge you to
apply what you've learned in new ways. To help you get the most practice in
the least time, you'll start these exercises from existing applications.
• If you page through this book, you'll see that all of the information is
presented in "paired pages," with the essential syntax, guidelines, and
examples on the right page and the perspective and extra explanation on the
left page. This helps you learn faster by reading less... and this is the ideal
reference format when you need to refresh your memory about how to do
something.

What you'll learn in this book


• In section 1, you'll learn the concepts and terms that you need for web
programming. You'll learn how to use the MVC pattern to structure your
web applications. And you'll learn how to use the NetBeans IDE with a
Tomcat server to develop servlets and JSPs for web applications. When
you're done with this section, you'll be ready to learn how to code and run
servlets and JSPs on your own computer.
• In section 2, you'll get a crash course in HTML and CSS, which is essential
to the use of JSPs. Then, you'll learn the skills for creating servlets and JSPs
that you'll need for almost every application. These chapters move from the
simple to the complex as they show you how to work with servlets, JSPs,
sessions, cookies, JavaBeans, Expression Language (EL), the JSP Standard
Tag Library (JSTL), and custom JSP tags.
• In section 3, you'll learn how to use both JDBC (an older access method)
and the newer Java Persistence API (JPA) to work with a database. Since
MySQL is a popular open-source database that is commonly used for web
applications, this section shows how to work with it, but these principles can
be applied to the use of any database.
Introduction XIX

• In section 4, you'll learn the advanced servlet and JSP skills that you
will need for certain types of web applications. This includes the use of
JavaMail, SSL, authentication, encryption, HTTP, listeners, and filters.
Then, it ends with an introduction to JavaServer Faces (JSF), an alternate
approach to JSP. Since we designed the chapters in this section to work
independently of each other, you can read them in any order you want. This
makes it easy to learn new skills whenever you need them.
• To complete your Java web programming skills, section 5 presents an
e-commerce website that puts the skills presented in the first four sections
into context. This downloadable application illustrates best practices
and provides code that you can use in your own applications. Once you
understand how this website works, you will have all the skills you need for
creating your own web applications.

What operating systems this book supports


The software you need for developing web applications with servlets and JSP
is available for Windows, Mac OS X, and Linux. If you're using Windows, you
can use appendix A to download and install this software. If you're using Mac
OS X, appendix B shows how to download and install this software. If you're
using another platform such as Linux, you probably already know how to install
this software! If not, you can use appendix B as a general guide and search the
Internet for more information if you need it.

How to get the software you need for this book


You can download all of the software that you need for this book for free
from the Internet. To make that easier for you, appendix A (PC) and B (Mac)
show how to download and install the software for this book. This software
includes Java SE, NetBeans, Tomcat, MySQL, and MySQL Workbench.

How our downloadable files make learning easier


To make learning easier, you can download the source code, files, and
databases for all the web applications presented in this book from our website
(www.murach.com). This includes the Music Store e-commerce application.
Then, you can view the complete code for these applications as you read each
chapter; you can compile and run these applications to see how they work; and
you can copy portions of code for use in your own web applications.
You can also download the starting points and solutions for the exercises
in this book. That way, you don't have to start every exercise from scratch.
This takes the busywork out of doing these exercises. As a result, you get more
practice in less time. In addition, if you encounter a problem, you can easily
check the solution. This helps you to keep moving forward with less chance that
you'll get stuck on a minor issue. For more information about these downloads,
please see appendix A (PC) or appendix B (Mac).
XX Introduction

Support materials for trainers and instructors


If you're a corporate trainer or a college instructor who would like to use
this book for a course, we offer an Instructor's CD that includes: (1) PowerPoint
slides, (2) test banks, (3) objectives, (4) additional exercises that aren't in this
book, (5) solutions to those exercises, (6) projects, and (7) solutions to those
projects.
To learn more about this Instructor's CD and to find out how to get it, please
go to our website at www.murach.com. Or, if you prefer, you can call Kelly at
1-800-221-5528 or send an email to [email protected].

Please let us know how this book works for you


When we started the first edition of this book, our goal was to teach you
how to develop real-world web applications with servlets and JSPs as quickly
and easily as possible. Now, with this third edition of this book, we hope we've
taken that to a new level. So if you have any comments, please email us at
[email protected].
Thanks for buying this book. Thanks for reading it. And good luck with your
web programming.

Joel Murach
Author
ection

Get started right


The three chapters in this section provide the background information that
you need for developing web applications with servlets and JavaServer
Pages (JSPs). In chapter 1, you'll learn what web programming is and how
servlets and JSPs work. In chapter 2, you'll learn how to use the MVC
pattern to structure a web application that uses servlets and JSPs.
Then, in chapter 3, you'll learn how to use the NetBeans IDE
(Integrated Development Environment) to work with the HTML, servlet,
JSP, and XML files that make up a servlet/JSP application. In addition,
you'll learn how to use NetBeans to run a Java web application on a
Tomcat server that's running on your computer.
An introduction to web
programming with Java
This chapter introduces some concepts and terms that you should learn before
you start web programming with servlets and JavaServer Pages (JSPs). In addi­
tion, it describes three approaches that you can use for developing Java web
applications. Finally, it describes some software that you can use to develop
and deploy serv let/JSP applications.

An introduction to web applications ....................................4


A typical web application ................................................................................4
The components of a web application .............................................................6
How static web pages work .............................................................................8
How dynamic web pages work ...................................................................... 10
Three approaches for Java web applications ................... 12
Servlet/JSP ..................................................................................................... 12
JSF.................................................................................................................. 12
Spring Framework ......................................................................................... 12
An introduction to servlet/JSP web development ............ 14
The software components.............................................................................. 14
The architecture ............................................................................................. 16
The standard directories and files ................................................................. 18
Software for developing Java web applications ...............20
IDEs for developing Java web applications ...................................................20
Web servers for Java web applications .......................................................... 22
Database servers for Java web applications................................................... 22
Tools for deploying Java web applications ................................................... 24
Perspective ...........................................................................26
4 Section 1 Get started right

An introduction to web applications


A web application is a set of web pages that are generated in response to
user requests. The Internet has many different types of web applications, such as
search engines, online stores, auctions, news sites, discussion groups, and games.

A typical web application


Figure 1-1 shows the first two pages of the shopping cart application that's
available from www.murach.com. Here, the first page presents some information
about our Java book. This page contains an Add To Cart link. When you click on
this link, the web application adds the book to your cart and displays the second
page, which shows all of the items in your cart.
The second page lets you change the quantity for an item or remove an item
from the cart. It also lets you continue shopping or begin the checkout process.
In this book, you'll learn all the skills you need to create a shopping cart applica­
tion like this one.
If you take a closer look at these web pages, you can learn a little bit about
how this application works. For the first page, the Address box of the browser
shows an address that has an htm extension. This means that the HTML code for
this page is probably stored in a file with an htm extension.
In contrast, the Address box for the second page shows the address of a
servlet that was mapped to the ordering/cart URL. This means that the HTML
code for this page was generated by a servlet. After the servlet address, you can
see a question mark and one parameter named productCode that has a value of
"htm5". This is the parameter that was passed from the first page.
Chapter 1 An introduction to web programming with Java 5

The first page of a shopping cart application


CJ @}

--
I:] Murach'sJava Progammi x

Cl
:=·
n1urach.cor11/books/javp/index.htm
Apps For quick acces�, place your bookmarks here on the bookmark� bar. Import bookmark� now... L] Other bookmarks

Home I Books I Dov,nloads I Trainers I Instructors I Customer Service I view cart I


Murach's Java Programming
by Joel t,lu ra ch
23 chapters, 802 pages, S40 illustrations
Published November 2011
ISBN: 978-1-890774-65-'3

Book price: S57.50; SAVE 30%, now just S4-0.25


eBook price: S47.50; SAVE 30%, nov, just S33.25
Book• eBook: S67.50; B-est Value! SAVE 30% 1 now Just 547.25

"f Jove your Java book. ft cuts :right to the essential information,
provjding the perfect balance betli'een too many details and too
little information. I bought another wel/-knovl'n Java book, but I
spent several hours trying to tearn what r learned from your book
in about 45 minutes." I add book I
I add ebook I
FREE do1Nnload of
sample chapters That's what one developer wrote us about an earlier edition of our
FREE download of the
�ook applications
core Java book. Now, you can expect th1at same practical, time­
saving approach in the current edition that covers the latest
I add both I
'.'\/hat soft,,vare you release of Java Standard Edition, Java SE 7 (or JDK 1.7).
More about the eBook
n��r1

The second page of a shopping cart application


CJ @}
Cl Mike Murach & AssociatE: x
Cl n1urach.cor11/ordering/cart?productCode = htmS --
:=· Apps For quick access, place your bookmarks here on the bookmark� bar. Import bookmark� now... L] Other bookmarks

Home I Books I Oov1nloads I Trainers I Instructors I Customer Service I view cart I


Your cart

Qty Description

!1 I [ Update I Murach's Java Programming [ Remove j


E � [ Update I Murach's HTML5 and CSS3 [ Remove j
To change the quantity, enter the new quantity and click on the Update button.

[ Continue Shopping ] I Proc eed t o Checkout ]

Do you have a pron1otion code to apply to this order?


If so, enter it here: [ =1
Other books related to what you just picked

Figure 1-1 A typical web application


6 Section 1 Get started right

The components of a web application


Figure 1-2 shows the basic components that make up a web application.
Because a web application is a type of c lientlserver application, the compo­
nents of a web application are stored on either the client computer or the server
computer.
To access a web application, you use a web browser that runs on a client
computer. One widely used web browser is Google Chrome, and a popular
alternative is Mozilla Firefox.
The web application itself is stored on the server computer. This computer
runs web server software that enables it to send web pages to web browsers.
Although there are many web servers, the Apache Software Foundation's Apache
HTTP Server is one of the most popular. Many developers refer to it just as
Apache.
Because most web applications work with data that's stored in a database,
most servers also run a database management system (DBMS), which is also
known as a database server. Two of the most popular for Java development are
MySQL and Oracle. When you use a database server, it doesn't have to run on
the same server as the web server software. In fact, a separate database server is
often used to improve an application's overall performance.
Although this figure shows the client and server computers connected via the
Internet, this isn't the only way a client can connect to a server in a web applica­
tion. If the client and the server are on the same Local Area Network (LAN), they
function as an intranet. Since an intranet uses the same protocols as the Internet,
a web application works the same on an intranet as it does on the Internet.
Chapter 1 An introduction to web programming with Java 7

Components of a web application


Client Server
computer computer

Internet

- connection
- I

Web Web server


browser Database server

Description
• Web applications are a type of client/server application. In a client/server applica­
tion, a user at a client computer accesses an application at a server computer. For a
web application, the client and server computers are connected via the Internet or
an intranet.
• In a web application, the user works with a web browser at the client computer. The
web browser provides the user interface for the application. One widely used web
browser is Google Chrome, but other web browsers such as Mozilla Firefox and
Internet Explorer are also widely used.
• A web application runs on the server computer under the control of web server
software. The Apache server is one of the most widely used web servers.
• For most web applications, the server computer also runs a database management
system (DBMS), which is also known as a database server. For servlet and JSP
applications, Oracle and MySQL are two of the most popular database management
systems.

Figure 1-2 The components of a web application


8 Section 1 Get started right

How static web pages work


HTML (Hypertext Markup Language) is the language that the browser
renders to the web pages that make up a web application's user interface. Some
web pages are static web pages, which are the same each time they are viewed.
In other words, they don't change in response to user input.
Figure 1-3 shows how a web server handles static web pages. The process
begins when a user at a web browser requests a web page. This can occur when
the user enters a web address into the browser's Address box or when the user
clicks a link that leads to another page. In either case, the web browser uses a
standard Internet protocol known as Hypertext Transfer Protocol (HTTP) to send
a request known as an HTTP request to the website's server.
When the web server receives an HTTP request from a browser, the server
gets the requested HTML file from disk and sends the file back to the browser
in the form of an HTTP response. The HTTP response includes the HTML
document that the user requested along with any other resources specified by the
HTML code such as graphics files.
When the browser receives the HTTP response, it renders the HTML
document into a web page that the user can view. Then, when the user requests
another page, either by clicking a link or typing another web address in the
browser's Address box, the process begins again.
Chapter 1 An introduction to web programming with Java 9

How a web server processes static web pages


Client Server
HTTP
request

HTTP
response

Description
• Hypertext Markup Language (HTML) is the language that the web browser converts
into the web pages of a web application.
• A static web page is an HTML document that's stored in a file and does not change
in response to user input. Static web pages have a filename with an extension of
.htm or .html.
• Hypertext Transfer Protocol (HTTP) is the protocol that web browsers and web
servers use to communicate.
• A web browser requests a page from a web server by sending the server a message
known as an HTTP request. For a static web page, the HTTP request includes the
name of the HTML file that's requested.
• A web server replies to an HTTP request by sending a message known as an HTTP
response back to the browser. For a static web page, the HTTP response includes
the HTML document that's stored in the HTML file.

Figure 1-3 How static web pages work


10 Section 1 Get started right

How dynamic web pages work


In contrast to a static web page, a dynamic web page changes based on the
parameters that are sent to the web application from another page. For instance,
when the Add To Cart button in the first page in figure 1-1 is clicked, the static
web page calls the web application and sends one parameter to it. Then, the web
application generates the dynamic web page and sends the HTML for it back to
the browser.
Figure 1-4 shows how this works. When a user enters data into a web page
and clicks the appropriate button, the browser sends an HTTP request to the
server. This request contains the address of the next web page along with any
data entered by the user. Then, when the web server receives this request and
determines that it is a request for a dynamic web page, it passes the request back
to the web application.
When the web application receives the request, it processes the data that the
user entered and generates an HTML document. Next, it sends that document to
the web server, which sends the document back to the browser in the form of an
HTTP response. Then, the browser displays the HTML document that's included
in the response so the process can start over again.
Chapter 1 An introduction to web programming with Java 11

How a web server processes dynamic web pages


Client Server
HTTP
request

HTTP
response

Description
• A dynamic web page is an HTML document that's generated by a web applica­
tion. Often, the web page changes according to parameters that are sent to the web
application by the web browser.
• When a web server receives a request for a dynamic web page, the server passes
the request to the web application. Then, the application generates a response, such
as an HTML document, and returns it to the web server. The web server, in turn,
wraps the generated HTML document in an HTTP response and sends it back to
the browser.
• Most modern web applications store and retrieve data from a database that runs on
a database server.
• The browser doesn't know or care whether the HTML was retrieved from a static
HTML file or was dynamically generated by the web application. Either way, the
browser displays the HTML document that is returned.

Figure 1-4 How dynamic web pages work


12 Section 1 Get started right

Three approaches
for Java web applications
There are many ways to develop Java web applications. Figure 1-5 describes
three approaches that are commonly used today. When developing Java web
applications, you typically use parts of the Java Enterprise Edition (Java EE)
specification. This specification describes how web servers can interact with all
Java web technologies including servlets, JavaServer Pages (JSP), JavaServer
Faces (JSF), Java Persistence API (JPA), Enterprise JavaBeans (EJB), and more.

Servlet/JSP
In a well-structured servlet/JSP application, servlets store the Java code that
does the server-side processing, and JavaServer Pages (JSPs) store the HTML
that defines the user interface. This HTML typically contains links to CSS and
JavaScript files. To run a web application that uses servlets and JSPs, you only
need to work with the servlet/JSP part of the Java EE specification.
Since the servlet/JSP API is a relatively low-level API, it doesn't do as much
work for the developer as the other two APis. However, the servlet/JSP API gives
the developer a high degree of control over the HTML, CSS, and JavaScript
that's returned to the browser. In addition, the servlet/JSP API is the foundation
for the other two approaches. As a result, it's a good place to get started with
Java web programming. As you progress through this book, you'll learn how to
develop servlet/JSP applications.

JSF
JavaServer Faces (JSF) is a newer technology that's designed to replace
both servlets and JSPs. It provides a higher-level API that does more work for
the programmer. When you use JSF, you typically use more Java EE features
than you do with the servlet/JSP approach.
When you use JSF, you can also use Enterprise JavaBeans (EJBs) to define
server-side components. Although there are some benefits to using EJBs, they're
overkill for most websites. As a result, this book doesn't show how to use them.

Spring Framework
Like JSF, the Spring Framework is a higher-level API that does more work
for the programmer than the servlet/JSP API. However, due to the way it's struc­
tured, the Spring Framework still gives the developer a high degree of control
over the HTML/CSS/JavaScript that's returned to the browser. As a result, if
control over HTML/CSS/JavaScript is a priority for your website, the Spring
Framework might be the right approach for you.
Chapter 1 An introduction to web programming with Java 13

Three approaches for developing Java web apps


Servlet/JSP
- Is a lower-level API that does less work for the programmer.
- Provides a high degree of control over the HTML/CSS/JavaScript that's
returned to the browser.
JSF
- Is a higher-level API that does more work for the programmer.
- Makes it more difficult to control the HTML/CSS/JavaScript that's returned to
the browser.
Spring Framework
- Is a higher-level API that does more work for the programmer.
- Provides a high degree of control over the HTML/CSS/JavaScript that's
returned to the browser.

Description
• The Java Enterprise Edition (Java EE) specification describes how web servers can
interact with all Java web technologies including servlets, JavaServer Pages (JSP),
JavaServer Faces (JSF), Java Persistence API (JPA), and Enterprise JavaBeans
(EJB).
• In a well-structured servlet/JSP application, servlets store the Java code that does
the server-side processing, and JavaServer Pages (JSPs) store the HTML that
defines the user interface. This typically includes links to the CSS and JavaScript
for the user interface.
• JavaServer Faces (JSF) is a newer technology than servlet/JSP that provides a
higher -level API that replaces both servlets and JSPs. For more on JSF, see chapter
21.
• Java Persistence AP/ (IPA) is an API for working with databases. It can be used
with servlet/JSP, JSF, or Spring. For more on JPA, see chapter 13.
• Enterprise JavaBeans (EJB) can be used to define server-side components. Since
these components are overkill for most websites, they aren't described in this book.

Figure 1-5 Three approaches for developing Java web apps


14 Section 1 Get started right

An introduction to servlet/JSP
web development
This topic introduces you to servlet/JSP development. In particular, it pres­
ents the software components, application architecture, and standard directories
that you typically use when you develop Java web applications.

The software components


Figure 1-6 shows the primary software components for a servlet/JSP web
application. By now, you should understand why the server must run web server
software. In addition, to work with servlets and JSPs, the server must also run a
servlet/JSP engine, which is also known as a servlet/JSP container. In this book,
you'll learn how to use the Tomcat server. This server is one of the most popular
servers for Java web applications, and it includes both a web server and a
servlet/JSP engine.
For a servlet/JSP engine to work properly, the engine must be able to access
the Java Development Kit (JDK) that comes as part of the Java Standard Edition
(Java SE). The JDK contains the Java compiler and the core classes for working
with Java. It also contains the Java Runtime Environment (IRE) that's necessary
for running compiled Java classes. Since this book assumes that you already
have some Java experience, you should already be familiar with the JDK and the
JRE.
Since all servlet/JSP engines must implement the servlet/JSP part of the Java
EE specification, all servlet/JSP engines should work similarly. In theory, this
makes servlet/JSP code portable between servlet/JSP engines and application
servers. In practice, though, there are minor differences between each servlet/JSP
engine and web server. As a result, you may need to make some modifications to
your code when switching servlet/JSP engines or web servers.
Since most servlet/JSP web applications store their data in a database, the
server typically runs a database server too. In this book, you'll learn how to use
MySQL as the database server. This software is open-source and commonly used
with servlet/JSP applications.
Chapter 1 An introduction to web programming with Java 15

The components of a servlet/JSP application


Client

HTTP HTTP
request response

Server

Description
• A servlet/JSP application must have a web server and a servlet/JSP engine, also
known as a servlet/JSP container, to process the HTTP request and return an HTTP
response, which is typically an HTML page. Most servlet/JSP applications use
Tomcat as both the web server and the servlet/JSP engine.
• Most servlet/JSP applications use a database to store the data that's used by the
application. Many servlet/JSP applications use MySQL as the database, though
there are many other databases to use.
• For a servlet/JSP engine to work, it must have access to Java's Java Development
Kit (JDK), which comes as part of the Java Standard Edition (Java SE). Among
other things, the JDK contains the core Java class libraries, the Java compiler, and
the Java Runtime Environment (IRE).

Figure 1-6 The components of a servlet/JSP application


16 Section 1 Get started right

The architecture
Figure 1-7 shows the architecture for a typical web application that uses
servlets and JSPs. This architecture uses three layers: (1) the presentation layer,
or user interface layer, (2) the business rules layer, and (3) the data access
layer. In theory, the programmer tries to keep these layers as separate and
independent as possible. In practice, though, these layers are often interrelated,
and that's especially true for the business and data access layers.
The presentation layer consists of HTML pages and JSPs. Typically, a web
designer works on the HTML stored in these pages to create the look and feel of
the user interface. Later, a Java programmer may need to edit these pages so they
work properly with the servlets of the application.
The business rules layer uses servlets to control the flow of the application.
These servlets may call other Java classes to store or retrieve data from a data­
base, and they may forward the results to a JSP or to another servlet. Within the
business layer, Java programmers often use a special type of Java class known as
a JavaBean to temporarily store and process data. A JavaBean is typically used
to define a business object such as a User or Invoice object.
The data layer works with the data of the application on the server's disk.
Typically, this data is stored in a relational database such as MySQL. However,
this data can also be stored in text files, binary files, and XML files. Or, it can
come from web services running on the other servers.
Chapter 1 An introduction to web programming with Java 17

The architecture for a typical servlet/JSP application


Presentation layer

Business rules layer

Data access layer

Description
• The presentation layer for a typical servlet/JSP web application consists of HTML
pages and JSPs.
• The business rules layer for a typical servlet/JSP web application consists of
servlets. These servlets may call other Java classes including a special type of Java
class known as a JavaBean. As you progress though this book, you'll learn how to
use several special types of tags within a JSP to work with JavaBeans.
• The data access layer for a typical Java web application consists of classes that
read and write data that's stored on the server's disk drive.
• For most web applications, the data is stored in a relational database such as
MySQL. However, it may also be stored in binary files, text files, or XML files.

Figure 1-7 The architecture for a servlet/JSP web application


18 Section 1 Get started right

The standard directories and files


Figure 1-8 shows a simplified version of the directory structure for the
Music Store application that's presented at the end of this book. Some of these
directories are part of the servlet and JSP specifications. As a result, they are
standard for all web applications. For example, all web applications that use
servlets must have the WEB-INF and WEB-INF\classes directories. In addition,
you can optionally include other standard directories such as the WEB-INF\lib
directory or the META-INF directory.
Of course, to organize and structure an application, a programmer can create
other directories within these directories. In this figure, for example, the admin,
cart, and download directories organize the Administration, Cart, and Download
sections of the Music Store application.
To start, each web application must have a root directory. This directory
can be referred to as the document root directory, or just document root. In this
figure, the document root directory is named musicStore, and it is subordinate
to Tomcat's webapps directory. Then, all of the other directories and files for the
application must be subordinate to this document root directory.
The WEB-INF directory that's subordinate to the document root directory
typically contains a web.xml file for the application. You'll learn more about
this file in the next chapter. In addition, you can use this directory or any of its
subdirectories to store files that you don't want to be directly accessible from the
web. For example, some applications in this book use the WEB-INF directory to
store data files. This prevents users from directly accessing these files.
The WEB-INF directory also has a few standard directories that are subor­
dinate to it. In particular, the WEB-INF\classes directory is the root directory
for all Java classes for the application that aren't stored in JAR files, including
servlets. Typically, these are the classes that you write. In contrast, the
WEB-INF\lib directory contains the JAR files that contain any Java class librar­
ies for the application. Typically, you get these JAR files from a third party.
Remember, though, that Tomcat's lib directory stores the JAR files for the class
libraries that are available to all web applications running on the web server. As a
result, you only use the WEB-INF\lib directory if you want to make the JAR file
available to just that one application.
To organize the classes that you create for the application, you can store
them in packages. In that case, you need to create one subdirectory for each
package. For example, this figure shows five packages. T hree of these packages
(music.admin, music.cart, and music.download) contain servlets that work with
the Administration, Cart, and Download sections of the application while the
other two contain the Java classes that provide the business objects
(music.business) and data access objects (music.data) for the application.
As you progress through this book, you'll learn how to use some other
standard directories and files to deploy web applications. For example, if you
want to use the database connection pool that's available from Tomcat, you can
modify the context.xml file that's stored in the META-INF directory as described
in chapter 12. For now, though, this figure should give you a general idea of what
it takes to deploy a web application.
Chapter 1 An introduction to web programming with Java 19

The directory structure for a web application named musicStore


W tomcat
:...... webapps
:......• musicStore (the root directory for HTML and JSP files)
····· admin
····· cart
····· catalog
···· META-INF (content.xml file)
:
:....• WEB-INF (the web.xml file)
:...... classes (the root directory for Java classes)
:......• music
business
controllers
.. . . . data
. ····· util
i ......• lib (JAR files for Java class libraries)

A summary of the directories and files for a web application


Directory Description
(root) This directory and its subdirectories typically contain the
HTML and JSP files for the application.
\WEB-INF This directory typically contains a file named web.xml.
You can use this file to configure the servlets and other
components that make up the application. In addition, this
directory is not directly accessible from the web.
\WEB-INF\classes This directory and its subdirectories contain the servlets
and other Java classes for your application. Each subdirec­
tory must correspond with the package for the Java class.
\WEB-INF\lib This directory contains any JAR files that contain Java
class libraries that are used by the web application.
\META-INF This directory contains the context.xml file. You can use
this file to configure the web application context.

Description
• The top-level directory for a web application is known as its root directory.
• A Java web application is a hierarchy of directories and files in a standard layout
defined by the Java EE specification. All Java web applications must use the first
three directories that are summarized above.
• To make classes within a JAR file availa ble to more than one web application, you
can put the JAR file in Tomcat's lib directory.

Figure 1-8 The standard directories and files for a servlet/JSP web application
20 Section 1 Get started right

Software for developing Java


web applications
This topic presents some of the software options that you have for develop­
ing Java web applications.

IDEs for developing Java web applications


In the early days of Java web programming, programmers commonly used
text editors to enter, edit, compile, and test the HTML, JSP, Java, servlet, and
XML files that make up a web application. Today, however, many Integrated
Development Environments (IDEs) are available that make Java web program­
f
ming more ef icient.
Two of the most popular IDEs for developing Java web applications are
NetBeans and Eclipse. Both are open-source, and both are available for free.
Of the two, we think that NetBeans is easier to use, especially when you're
getting started with web programming. That's why we recommend that you use
NetBeans with this book.
In figure 1-9, for example, you can see the NetBeans IDE with the project
for chapter 2 in the Projects window, the code for a servlet class in the editor
window, and runtime messages in the Output window. This is similar to what
you'll find in most IDEs. As a result, once you're done with this book, you can
easily apply the skills that you learn with NetBeans to another IDE.
Although we recommend using NetBeans with this book, you should be able
to use another IDE with this book if you prefer. To do that, though, you will need
to figure out how to import the source code for this book into your IDE so you
can compile and run the sample applications and complete the exercises. In addi­
tion, you will need to use your IDE to perform the tasks presented in chapter 3.
Since the JDK, N etBeans, Tomcat, and MySQL can be run by most operat­
ing systems, Java web developers aren't tied to a specific operating system. In
fact, developers often use Windows or Mac OS X during development. However,
when the applications are ready for release, they are often deployed to a Linux or
Unix server.
Chapter 1 An introduction to web programming with Java 21

The NetBeans IDE


0 ch02e-mail - NetBe-ans IOE B.O I= I @J :·
cv, I

File Edit View Navigate Source Re-factor Run Debug Profile Team Tools Window Help IQ.• Search (Ctrl+I)

Projects • Files I I Services I g


� index.html •I� I
x Ll:!IIL.-�...;...;�-1..
Emaillistservlet.java rll1 thanks.jsp i:& I 818 G@J
s-� ch02email I '1? �
�����������������__,::::::::....:::...::::,
% I <::iii �� I O D 11/Q! !
I� •
Source History I � (B • � • I to_ '¢ � � :::::� I EB
$m Web Pages package murach.email;
! El META-INF �
! iii � WEB-INF 3 S import java.io. ";
i 13...� styles 4 import javax.servlet.*;
i !· [!I
! L....�
index.html
thanks.jsp
s import javax. servlet.http."; -
6
$@ Source Packages 7 import murach.business.User; -
! El··· E!3 murach.business
e - import m.urach.data.OserDB;
i iii § murach.data 9
! El
§3 murach.email 10 public class EmailLi.stSerwlet extends HttpServlet {
i L. Ii E maillistservlet.java 11
$ (R "J:est Packages 12 @override
9.. � Libraries @ protected void doPost(HttpServletRequest request,
i:p � TestL1braries 14 HttpServletResponse response)
El··� Configuratiori Files 1s G throws ServletException, IOException {
i!J-� ch04email

do Post - Navigator x I
16
17 String url = "/index.htnl"; -
..-11 ..-1
Q
18
Members <empty> LaJ 19 t/ get c�rre�t act10�
&'.> Emaillistservlet : : HttpServlet 20 String action= request.getParameter("action"); ...
!·· 'ft:>
doGet(HttpSe-rvletRequestrequest, H
L.t:J doPost(HttpServletRequest request, I :===::;::: = ===============
t)
� Emaillistservlet )

Output I Ii
=============== =======:
doPost ) url ) X

• ch02emai (run) n I Tomcat 8.0 Log R I Tomcat8.0 ae I


• J .o--��.��������������-����--,
11-Apr-2014 15: 48: 44 _394 INFO (:m&i. n] erg_ apac:h@ _ceyetoLAb:!ltrac:tPretocel _!ltart Starting Protoc:oll •
11-Apr-2014 15: 48: 44 _ 399 INFO (:m&i.n] erg_apac:h@ _ cata.lina _,.ta.rtup.Catali.na_ :!ltart S@rv@r Bta.rtup :
11-Apr-2014 15:48:46_047 INFO lihttp-nio-8080-exec-41 org_apache_catalina_core_StandardContext.r1
11-Apr-2014 15: 48: 47. l 7f> INFO llhttp-nio-8080-exec-4 I org .apache- ca:calina._ c:ore. Sta.nda.rdContext. rc
c::::i

�1 rrr J

17:36 I INS

Popular IDEs for Java web development


NetBeans
Eclipse
IntelliJ IDEA

Description
• An Integrated Development Environment (/DE) is a tool that provides all of the
functionality that you need for developing web applications.
• NetBeans and Eclipse are popular IDEs for Java web development that are
open-source and free.
• Chapter 3 shows how to use NetBeans for developing Java web applications. We
recommend using this IDE with this book.

Figure 1-9 IDEs for developing Java web applications


22 Section 1 Get started right

Web servers for Java web applications


Figure 1-10 describes two popular web servers for Java web applications.
This book shows how to use the Tomcat server, which is the most popular server
for Java web applications. Tomcat includes a web server named Coyote and a
servlet/JSP engine named Catalina. As a result, this server can work with the
servlet/JSP part of the Java EE specification.
In contrast, the GlassFish server implements the complete Java EE specifica­
tion. Since it's more than just a servlet/JSP engine, it's known as an application
server. The advantage of using an application server like GlassFish is that it
provides more features for working with other parts of the Java EE specification
such as JSF and JPA. One disadvantage is that it requires more system resources
than Tomcat. As a result, it may not run as quickly on your computer.
This figure also lists four other popular web servers for Java applications.
These web servers include WildFly, which was formerly known as JBoss, Jetty,
Oracle WebLogic, and IBM WebSphere. Each server implements some or all of
the Java EE specification, and each server has its advantages and disadvantages.

Database servers for Java web applications


This figure also describes the most popular database server for Java web
applications, the MySQL database server. This is the database server that you'll
learn to use in this book. Like Tomcat and GlassFish, MySQL is open-source
and runs on all modern operating systems. In addition, MySQL implements most
of the SQL standard. As a result, database code developed for the MySQL server
should be mostly portable between database servers.
Although many Java web applications use a MySQL database, some devel­
opers prefer other open-source databases, such as PostgreSQL. On the other
hand, some large enterprises prefer using a proprietary database like Oracle to
store mission-critical data.
Chapter 1 An introduction to web programming with Java 23

Two popular web servers


Tomcat
- Is a servlet/JSP engine that includes a web server.
- Is free, open-source, and runs on all modern operating systems.
- Is a popular web server for Java web applications.

GlassFish
- Is a complete Java EE application server.
- Is free, open-source, and runs on all modern operating systems.
- Provides more features than Tomcat.
- Requires more system resources than Tomcat.

Other popular web servers


- WildFly (formerly JBoss)
- Jetty
- Oracle WebLogic
- IBM WebSphere

A popular database server


MySQL
- Is a relational database server that implements most of the SQL standard.
- Is free, open-source, and runs on all modern operating systems.
- Is the most popular database server for Java web applications.

Other popular database servers


- PostgreSQL
- Oracle

Description
• A servlet/JSP engine is the software that allows a web server to work with the
servlet/JSP part of the Java EE specification.
• Tomcat is one of the most popular servlet/JSP engines. It includes a web server
named Coyote and a servlet/JSP engine named Catalina.
• A Java EE application server is the software that allows the web server to work
with the entire Java EE specification including servlets, JSP (JavaServer Pages),
JSF (JavaServer Faces), JPA (Java Persistence API), EJB (Enterprise JavaBeans),
and so on.
• GlassFish is one of the most popular application servers. It includes a web server, a
servlet/JSP engine that's based on Tomcat's servlet/JSP engine, and more.
• MySQL is one of the most popular database servers.

Figure 1-10 Web and database servers for Java web applications
24 Section 1 Get started right

Tools for deploying Java web applications


Once you've tested your servlets and JSPs on your own computer or an
intranet, you may want to deploy your web application on the Internet. To do
that, you need to get a web host. One way to do that is to find an Internet service
provider (ISP) that provides web hosting that supports servlets and JSPs. If you
read the text for the ISP on the web page shown in figure 1-11, for example, you
can see that this ISP supports servlets and JSPs.
If you search the web, you'll be able to find many other ISPs and web hosts.
Just make sure that the one you choose not only supports servlet and JSP devel­
opment, but also the database management system that your application requires.
When you select a web host, you get an IP address like 64.71.179.86 that
uniquely identifies your website (IP stands for I nternet Protocol). Then, you can
get a domain name like www.murach.com. To do that, you can use any number
of companies that you can find on the Internet. Until you get your domain name,
you can use the IP address to access your site.
After you get a web host, you need to transfer your files to the web server.
To do that, you can use File Transfer Protocol (FTP). The easiest way to use
FTP is to use an FTP client such as the FileZilla client shown in this figure. An
FTP client like this one lets you upload files from your computer to your web
server and download files from your web server to your computer.
Chapter 1 An introduction to web programming with Java 25

An ISP that provides web hosting that supports servlets and JSPs
E] JSP Web Hosting and Sel'\ )(

C [j www.mmaweb.net --
•••
:· Apps For quick access, place your bookmarks here on the bookmarks bar. Import bookmarks now ... D Other bookmarks

web bostios sales FAQs Account Log11


(716) 689-1593

,-. HOHE HOSTING SERVICES S\JPPORT ORDER A.BOUT US SOFTWARE

Private JVM with Every


Account!
Don't have a domain yet? See if
yours is available by checking
our whois gateway:

Domain (.com. .net, .org)

L I ,--1 $49.99
--.
C-h e- ck j JSP hosting and servlet hosting accounts ·with CCOUNT
per..-.Ch'
advanced, scalable server technologies like Servlets,
Java Server Pages (JSP). Enterprise JavaBeans
(EJB) and XML are what MMA specializes in.
Java Developer Links
The result is a continuous upgrade • Plu, one-month setup fee st
• SeNlets.com
path that lets small businesses ,isJt of first month.
launch websites built on proven
• JsvaWotld
technology that can grow as you
• Official SeNlet Home achieve success without the need
• JsvaSeN!H Pages Home
_.......,_
to rebuild and redeploy your core

The FileZilla program


fi) murach.com - classes - [email protected] m - FileZilla
File Edit Vi� Transfer Server Bookmarks. Help

I � ·ILC1iltiiJI � -. 13 �I��� n
I Host:
Status:
Respoose:
User.name: Password:
Connection established, waiting for welcome message ...
227 Entering Passive !Mode (72,9,137,30, 138,150)
Port: [ Quick.connect ] r:;l
-
Command: MLSD
Response: 150 Accepted data connection
Respoose: 226-0ptions: ..a�
Response: 226 4 matches total D
Status: !Directory listing successful

Local site: 1t\Web Site'vnurach_web4\/:,uild'"'eb\\�/EB-,INF\dassesvnurach\fv\ ..- Remote site: /htclocs/WEB-INF/dasses/mur.ach/fv


,customers j ... ?, customers
,custserv I ... ? custserv
downloads D L. .? downloads D
.... /..... • fv

fv
i
Filename Filesize Filetype Filename Filesize Filetype
- ..
D Financial Calculations.class 747 CLASS File D Financial Calculations.class 747 CLASS Fil
Dlliliiiilli lllliltilli LJ FutureValueServlet.class 2,389 CLASS Fil

m
t-----
" < I Ill
Selected 1 file. Total size: 2,389 Open 2 files.Total size: 3,136 byte.s
Edit
Server/local file Size Priority Status
Create directory
Refresh

Queued files Failed tra Delete


Rename
[!] IHI Queue: empty

Figure 1-11 Tools for deploying Java web applications


Another Random Document on
Scribd Without Any Related Topics
The Project Gutenberg eBook of The Dabistán,
or School of manners, Volume 2 (of 3)
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: The Dabistán, or School of manners, Volume 2 (of 3)

Dubious author: Muhsin Fani

Translator: David Shea


Anthony Troyer

Release date: September 23, 2020 [eBook #63276]


Most recently updated: October 18, 2024

Language: English

Credits: Produced by Édith Nolot, Carol Brown, Richard Hulse,


Bryan
Ness and the Online Distributed Proofreading Team at
https://www.pgdp.net (This file was produced from
images
generously made available by The Internet
Archive/American
Libraries.)

*** START OF THE PROJECT GUTENBERG EBOOK THE DABISTÁN,


OR SCHOOL OF MANNERS, VOLUME 2 (OF 3) ***
THE DABISTÁN,
OR

SCHOOL OF MANNERS.
Madame Veuve Dondey-Dupré,
Printer to the Asiatic Societies of London, Paris, and Calcutta,
46, rue St-Louis, Paris.
THE

DABISTÁN,

OR

SCHOOL OF MANNERS,
TRANSLATED FROM THE ORIGINAL PERSIAN,
WITH NOTES AND ILLUSTRATIONS,

BY

DAVID SHEA,
OF THE ORIENTAL DEPARTMENT IN THE HONORABLE EAST INDIA
COMPANY’S COLLEGE;

AND

ANTHONY TROYER,
MEMBER OF THE ROYAL ASIATIC SOCIETIES OF GREAT BRITAIN
AND IRELAND, OF CALCUTTA AND PARIS, AND OF THE
ETHNOLOGICAL SOCIETY OF PARIS;

EDITED, WITH A PRELIMINARY DISCOURSE, BY THE


LATTER.

VOLUME II.

PARIS:
PRINTED FOR THE ORIENTAL TRANSLATION FUND OF GREAT
BRITAIN AND IRELAND.
SOLD BY
BENJAMIN DUPRAT, BOOKSELLER TO THE BIBLIOTHÈQUE ROYALE,
7, RUE DU CLOITRE SAINT-BENOIT.
AND ALLEN AND CO., LEADENHALD-STREET, LONDON.
1843.
THE DABISTÁN,
OR

SCHOOL OF MANNERS.

CHAPTER II.

The second chapter of the Dabistan describes in twelve sections the


religious systems of the Hindus:
Section 1. Concerning the tenets of the Búdah-Mímánsa, the
followers of which are also called Samártikan (Smártís), or
“legalists,” and are orthodox Hindus.
Sect. 2. Records some of their opinions relative to the creation:
their Purans (Tarikhs), or “histories,” treat of the same subject.
Sect. 3. The religious ceremonies and acts of the Smártís, and
their orthodoxy.
Sect. 4. Treats of the followers of the Vedanta, who form the
philosophers and Súfís of this sect.
Sect. 5. Concerning those who profess the Sankhya doctrines.
Sect. 6. Treats of the Jogís and their doctrines.
Sect. 7. Describes the tenets of the Saktíán.
Sect. 8. The opinions and ceremonies of the worshippers of
Vishnú.
Sect. 9. Treats of the Chárvákián.
Sect. 10. Describes the system of the Tárkikán, who are profound
investigators and deep thinkers in theology.
Sect. 11. On the tenets held by the followers of Búdah (Buddha).
Sect. 12. On various religious systems professed by the people of
India.

Section the first—concerning the orthodox Hindoo system. As


inconstant fortune had torn away the author from the shores of
Persia, and made him the associate of the believers in transmigration
and those who addressed their prayers to idols and images and
worshipped demons, therefore the tenets held by this most subtle
class of reasoners come to be considered next after those of the
Parsees. It is however necessary to premise, that among the Hindus
there are many systems of religion, and innumerable creeds and
ceremonies: but there is one principal class of this people (as will be
shown in the tenth chapter), and its rank and dignity will be brought
into evidence.
Like Zardusht and the sages of antiquity, they have recourse to
metaphorical and enigmatical figures of speech, as will appear
evident in the course of this narration. Long before the present
work, the author had from books ascertained their various systems,
according to a plan which he now voluntarily abandons; as in the
year of the Hejirah 1063 (A. D. 1653), whilst sojourning at Srikakul,
the capital of Kalinga,[1] certain eminent persons who were the
author’s intimate friends, had travelled in that direction for the
purpose of visiting their holy stations; one day a conference took
place, on which the author reviewed anew what he had before
heard, and with the pen of accuracy drew the line of erasure over all
that was doubtful; so that there was found a wide difference
between the first and second work on these points.

Summary of the doctrines contained in the Budah Mimansa.[2] The whole


world is not governed by the orders of a real Lord, and there is in
truth no reality in his actual existence. Whatever of good or evil,
reward or punishment, attaches to created beings, is entirely the
result of their acts, deeds, and words; mortals are altogether captive
in the trammels of their own works, and confined in the chains of
their own deeds: without previous acts they are liable to no
consequences. The sovereign, Brahma, the creator of all things; the
angelic Víshnu, their preserver; and Mahesh, or Siva, the destroyer
of existences, attained to this exalted eminence through means of
righteous acts and holy deeds; nay, Brahma, through the efficacy of
worship, the power of obedience, the might of his religious
austerities, and by his good actions, created the world; agreeably to
the express declaration of the Véda,[3] which according to the belief
of the Hindus is a celestial revelation, every dignity of the celestial
orders is inseparably connected with meritorious works and holy
deeds; and as the intellectual soul is of the same nature as the
angelic essence, the possessor may, by the exercise of angelic
qualities, become one of those exalted dignities, and during a
lengthened but definite period, be invested with power and glory.
For instance, the human spirit, which in knowledge and good works
has attained to a degree accounted worthy of the rank of Brahma,
is, on the termination of the period of sovereignty assigned to the
present Brahma, appointed to that predestined dignity: the same
principle also applying to the other angelic degrees.
This tenet therefore leads to the same inference as the opinions
entertained by the distinguished Parsee sages, namely: that the
spirits of men, on attaining complete perfection, become united to
the heavenly bodies, and after many revolutions, the celestial souls
are blended with the divine intelligences. According to the Mobed:
“The cup-bearer poured into the goblet the wine of the celestial soul,
And filled the nine empyreal domes with the beverage of human spirit.”

The world has neither beginning nor ending; moreover all spirits
are enchained in the bonds of their own acts and deeds; so that the
spirit of high rank which adopts the practices of the inferior, cannot
attain to the sublime rank peculiarly assigned to exalted conduct;
and the inferior spirit, sedulously given up to the works of those
eminent in dignity, is enabled to obtain that glorious pre-eminence;
so that their meritorious works confer on them knowledge; and the
purity of their intellects, in proportion to their elevation, conducts
them to high degrees and praiseworthy deeds. The dominion
obtained by an animal body over the human soul arises from works;
as in their members, physical structure, and senses, all men are
fashioned after one model; but through the cause of becoming or
unbecoming deeds, one is a sovereign ruler, and another a destitute
dependent. Thus, through the influence of praiseworthy acts, one is
honored and opulent; and owing to a subservience to foul deeds,
another lives degraded and indigent; the high and dignified agent of
opulence and honor falls not into the depths of poverty, nor does the
wretched slave to acts of covetousness and avarice ever attain the
dignity of honor and riches. The world is the root and productive soil
of works, and time is their developer; because, when their time
comes, it brings the fruit, just as every season produces the flowers,
sweet-scented plants, and fruits suitable to the period; in like
manner, the result of every act, whether deserving of praise or
censure, is made to adhere to its agent, in whatever revolution that
may be proper for it. Works are divided into two kinds: those which
are to be performed; the other, those which are to be avoided:
under the first, come those acts, the performance of which is
enjoined in the Vedas, or the celestial revelation, such as the
established worship and the requisite acts of obedience which prevail
among the Hindoos; under the second head come those acts, the
committing of which is forbidden by the text of the celestial code;
such as shedding blood, theft, immoral practices, and other similar
acts there enumerated. The supreme Lord stands not in need of our
adoration and obedience, nor is he in any want of us for the
performance of the above-mentioned duties at our hands; but the
results of our acts and deeds, in reference to rewards and
punishments, accrue and adhere to us. For instance, if the invalid
should adopt habitual moderation, he obtains that health which is
the object of his wishes, and his existence is thereby rendered
happy; but should he, from a bias to reprehensible pleasures, the
concomitants of disease, withdraw from the restraints of abstinence,
his life becomes embittered; the physician, in either case, being
totally independent of the patient’s welfare and sufferings. Moreover,
the world is the abode of disease, and human beings are the
patients: if they acquit themselves in the most perfect manner of
their prescribed duties, and strenuously avoiding what ought not to
be done, they attain the state of health, the most elevated degree of
which is liberation from this degraded body, and union with the
ambrosial sweets of paradise; which state is called Mukti by this
sect; and the mode of attaining the highest degree of Mukti is not
being immersed in the pleasures of this world, plucking away the
heart from the gratifications of sense, being content with mere
necessaries, abstaining from food, breaking the fast with viands not
relished by the vile appetite, and such like: just as in sickness, for
the sake of dissolving the morbid matter, it becomes necessary to
fast one day, and to swallow bitter draughts.
Such is the substance of the tenets professed by the sect entitled
Budah-Mimansá, which coincide exactly with those of the
Yezdáníáns, except that the latter admit the being of the self-
existent God, the sole and true object of adoration; regarding the
acts and deeds performed in this world as the means of elevation
and degradation in the next; holding the angelic dignities to be
imperishable; and esteeming human perfection to consist in
attaining to the society and service of the sublime assembly in the
court of heaven; whilst the followers of the Budah Mimansa do not
admit the existence of the eternal and infinite Lord; but according to
them, the term “Almighty” signifies the human soul, acts, and deeds.
They also assert, that the blessings of paradise are transitory, and
that the angelic dignities are liable to perish. However, the orthodox
opinion, which is most prevalent at this time, is this: they admit the
being of the truly-existing God, by whom the world subsists; but
account his holy essence altogether exalted, and exempt from
whatever effects created beings. They also believe that human
beings are confined by the yokes of their own works, and enchained
by their deeds, in the manner before stated.

[1] The name of a country: this name is applied in the Puranas to


several places, but it usually signifies a district on the Coromandel coast,
extending from below Cuttack to the vicinity of Madras.—D. S.
[2] ‫ بوده ميمنس‬is the reading of the edition of Calcutta; the same
spelling of Budh, or Budah, is found when the name of the legislator,
properly Buddha, is introduced, as in p. 175 of the same edition, and
elsewhere. But Budah may also signify “past, gone,” and therefore “prior;”
on that account D. Shea rendered the above name by Purva (or “prior”)
Mimansa. According to Colebrooke and Mr. Wilson, मीमांसा Mímánsá,
signifies one of the philosophical systems of the Hindús, or rather a two-
fold system, the first part of which is the Purva Mímánsá, or Mímánsá,
simply; the second part, the Uttara Mímansa. “The prior Mímánsá,
founded by Jaimini, teaches the art of reasoning, with the express view of
aiding in the interpretation of the Vedas. The Uttara, or “latter,” commonly
called the Vedanta, and commonly attributed to Vyasa, deduces from the
Vedas a refined psychology, which goes to the denial of a material
world.”—(Colebrooke’s Essays.)
But the above account of the Dabistán is not strictly and fully in
accordance with this definition of the first Mímánsá, because it exhibits
more of the Puranic than of the Vedáic doctrine, not without some
particular notions. It appeared therefore best to adhere to the reading of
the original text.—A. T.
Védá, the generic term for the sacred writings, or scriptures, of the
[3]
Hindús. See a subsequent note about the four Védas.

Section the second treats of certain opinions entertained by this sect


concerning the creation: a subject which is also discussed in their puranas
or histories.—In the second part of the Bhagavat, one of their most
esteemed Puránás, it is recorded that the Almighty Creator, in the
beginning, first placed the mantle of existence on the bosom of
Prakriti,[4] or “nature,” and produced the fourteen Bhuvanas,[5] or
“worlds.” The first sphere is that of the earth, which has been
estimated by some of the ancients at five Kotes (50 millions) of
Yojans,[6] each Kote being equal to one hundred Lakhs (10 millions)
and each Jojun to one Parasang and one-third; above the terrestrial
is the aqueous sphere; above which is that of fire; beyond which is
the aërial, over the celestial; beyond which is the Ahankar,[7] or that
of “consciousness;” and higher than this is the Mahat-tat (Mahat-
tatwam)[8] or “essence,” which is equal to ten of those below it; and
Prakrit having enveloped it, intelligence penetrating through all the
things before said, rises above: on earth it becomes knowledge; by
means of water, there is taste; by means of fire, form; by means of
air, the touch of cold and dry; by means of the heavens, there is the
perception of sound; and the organs of perception, are the exterior
senses; and the internal sense is the seat of consciousness. In the
same part of the Bhagavat it is stated that, by nature, the heavens
are the vehicle of sounds; and consequently, the nature of the air
gives the perception of sound and touch; in all other bodies the air is
spirit, and from it arises the energy of the senses. To the nature of
fire belongs the perception of sound, touch and form; to the nature
of water, that of sound, touch, form, and savor; and to the nature of
earth, that of sound, touch, form, savor, and odor.
Of the fourteen created spheres, seven rise above the waist of
the Almighty, and the remaining seven correspond with the lower
part of his body; according to which enumeration the Bhú-lok,[9] or
the earth and terrestrial beings form “his waist;” the Bhúvanlok,[10]
or the space between the earth and sun, “his navel;” the Surlok,[11]
“his heart;” the Mehrlok,[12] “his breast;” the Jonlok,[13] “his neck;”
the Tapalok,[14] “his forehead;” the Satyolok,[15] “his head;” the
Atellok,[16] “his navel and podex;” the Batellok,[17] “his thigh;” the
Sotollok,[18] “his knee;” the Talátellok,[19] “the calf of the leg;” the
Mahátollok,[20] “the heel;” the Rasatollok,[21] “the upper part of the
foot;” the Pátállok,[22] “the sole of the foot.”
There is another division limited to three spheres: the Bhúlok,
“the sole of the Almighty’s foot;” the Bhuvarlok, “his navel;” the
Súrlók, “his head;” the whole fourteen gradations in detail are thus
reduced to three, signifying a mighty personage, the same as the
Deity.
In the same section of that volume it is also stated, that from the
Almighty sprang Svabhávah,[23] “the self-existing;” that is, Nature
and Time; from Nature and Time proceeded forth Prakrit, which
signifies Símáí, “universe;”[24] from Prakrit came forth Mahat-tat;[25]
and from this latter, which is the same as Mádah, “mental
exaltation,” issued the three Ahankárs, or modes of consciousness,
“personality, egotism,” Satek, Rajas, Tamas.[26] Satek, “goodness,”
means “the intellectual energy;” Rajas, or passion, “the attraction of
vile propensities,” or “sensual pursuits;” and Tamas (darkness), “the
repelling of what repugns,” in Arabic, Ghazab, or “wrath.” From Rajas
issued forth the senses; from Satek, the lords of nature and the
servants of the existing beings; and from Tamas came forth Shaid,
“enchantment;” Shuresh, “confusion;” Rup, “form;” Darsan, “sight;”
and Gandah, “smell;”[27] that is, hearing, touch, sight, taste, and
smell; from which five were produced the heavens, air, fire, water,
and earth. Also from the three above-mentioned properties (gunás)
the three mighty angels, Vishna, Brahma, and Mahísh, came into the
area of the creation.[28] Moreover, for the purpose of creation, eight
other Brahmas were also impressed by the first Brahma with the
characters of existence, and these became the various gradations of
the spiritual, corporeal, the high, the low, the mineral, vegetable,
and animal kingdoms.
In some of their treatises, God is the same as time, works, and
nature; whilst, according to others, these are regarded as the
instruments of his majesty.
In other treatises, the Almighty is held to be light, surpassingly
great and splendid, of exceeding brilliancy and radiance, corporeal,
invested with members.
Other descriptions represent him as pure light, abstract being,
simple existence, unconfined by place, exempt from transmigration,
free of matter, without parts, uncompounded, divested of the
attributes of accidents, and the creator of the world, and all therein
contained. According to other dissertations, God is the producer of
beginning and end, exhibiting himself in the mirror of pure space,
containing the higher and lower, the heavenly and terrestrial bodies.
It is stated in the first part of the Bhagavat, that the truly-existing
is an abstract being, one without equal or opposite, who in the
various languages amongst the human race has denominations
suited to the belief of his worshippers, and that the mode of
attaining union with him depends on eradicating wrath, extirpating
bodily gratifications, and banishing the influence of the senses. This
holy essence is called Naráyan,[29] whose heads, hands, and feet
exceed all number.
At the period when this world and all it contains were buried
under the waters, Tot, or “intellect” lay reclined in the sleep of unity,
on the head of Adsesh,[30] the supporter of the earth. From the navel
of this exalted being appeared the lotus flower, called by the
Hindoos Kawal;[31] out of which arose Brahma, from the members of
whose mighty existence all created beings hastened into the area of
visibility.
It is recorded in other treatises of this sect, that they give the
name of Naráyan, or “the majesty without color,”[32] that is, “without
the qualities of accidents,” to the absolute essence and abstract
being of God, who is in pure space. They say, moreover, that his
essence, which is devoid of all forms, made a personage called
Brahma, who was constituted the medium of creation, so that he
brought all other existences from behind the curtain of nonentity
into the luminous area of being. In like manner that sublime essence
manifested itself in the soul of Vishnu, so that he became an Avatár,
and to him is confided the preservation of whatever Brahma created.
That glorious essence next called up Mahadeo, for the purpose of
destroying Brahma’s creation, whenever infinite wisdom requires the
transformation of the visible into the invisible world; from which
three agents arises the arrangement of all things in the universe.[33]
They say that Brahma is an aged man with four heads; Naráyan, or
Vishnu, holds in his hand the Chakra, or Disk, “a sort of weapon;” he
always assumes the Avatárs, or “incarnations;” of which ten are
greatly celebrated. Avatár[34] means appearance or manifestation;
Karan[35] signifies cause; Brahma, Vishnu, and Mahadeo are called
Trikaran, or the three causes.
In the Satya-Jog there was a Rakshas[36], named Sámak Asur,
who performed such great religious austerities, that he became
enabled to work miracles; he having taken the Anant-Ved[37] which
was in Brahma’s possession, and from which are derived the four
Vedas given to mankind, fled into the water; on this, Vishnu, on the
fifth day of the fifth month, Chét,[38] “March-April,”[39] in the Kishn
Bichah, having assumed the Matsyávátar, or “the form of a fish,”
plunged into the water, slew the Rakshas, and recovered the Veda:
this was the first Avatar.
The second was the Kurmávátar, or “that of the tortoise.” Anant
Ved signifies “the numberless Vedas;” Matsya, “a fish;” Avatár,
“descent,” or “manifestation;” Chét, “the fifth solar month;” Kishn
Bicheh, “that portion of the month which is without moonlight and
when the nights are dark.”
On the twelfth of Chét, in the Kishn Bicheh, he assumed the
Kurmávátár, or “that of the tortoise.” They say that the Angels and
Deeves (Asurs), taking the serpent Vásukir,[40] formed with him a
cord, and fastening this to a lofty mountain called Mandára,[41] made
with it a churn-staff, which they moved about in the mighty ocean,
whilst Naráyan remained under the mountain to prevent it from
falling; and by this agitation they procured the water of life. In the
kingdom of Kalinga, they have formed the image of a tortoise, and
among the wonderful sights of that region is the following
miraculous event: if they cast the bones of a Brahman or a cow into
the adjacent reservoir, in the course of a year one half of it becomes
stone, and the other half remains unchanged. It is worthy of remark,
that some Persian astronomers represent the constellation Cancer by
a tortoise, nay call it by that name, instead of Kharchang, or “crab.”
Ferdúsi, the sage, thus expresses himself:
“The lunar lord beheld the ascendancy of the tortoise.”

And as they account Cancer the ascendant sign of the world, it is


therefore likely that the ancient Hindú philosophers represented this
constellation[42] under the figure of the Kurma, or “tortoise;” also by
the Matsya, or “fish,” is meant the constellation Hút, or “Pisces.”
The third was the Baráh, or “boar Avátar,” when a Rakshas,
named Karanyáksha, having taken away the earth and carried it
under the water, Vishnu, on the sixteenth of Chet in the Shakl
Pacheh,[43] or “bright half of the moon,” assumed the form of a boar,
slew the demon with his tusks and brought out the earth.
The fourth was the Narsinha, or “man-lion Avátar.” There was a
Rakshas named Kiranya Kashípú, whose son, Prahláda, worshipped
Vishnu, and as his father persecuted him on that account, Vishnu,
therefore, on the fourteenth of Baisakh,[44] in the Shakl Pacha, or
“bright half of the moon,” having assumed the form of the Narsingh,
whose head and claws were those of a lion joined to a human body,
slew the demon Kiranya Kashipú.
The fifth was the Vá-mana, or “dwarf Avatar.” When the Rakshas,
Bali daitya, through his religious exercises and austerities had
become lord of the three worlds, that is, of all above the earth and
below it and the heavens, so that the angels were hard pressed and
deprived of their power; Vishnu, therefore, on the twelfth of
Bhadun[45] in the Shakl Pachah, descended in the Vámanah Avátár,
and coming into the presence of Bali, requested as much of the
earth as he could traverse in three steps: to this Bali consented,
although Sukra, or “the planet Venus,” the director and guardian of
the demons, exhorted him not to grant the request, saying: “This is
Vishnu, who will deceive thee.” Bali replied: “If he come to me as a
suitor, what can answer my purpose better?” Vishnu, on this,
included the whole earth in one step, the heavens in the second,
and in the third, rising up to his navel, said to Bali, “Whither can I
pass?” Bali, on this, presented his head; on which Vishnu, who saw
this, having placed his foot, sent Bali[46] below the earth, where he
has ever since continued to reign with sovereign power, during many
hundred thousands of years. It is to be noted, that Vá-mana means
a dwarf, as he was a diminutive Brahman.
The sixth Avátar was Paras u Rama.[47] The Chatri, or “military
caste,” having become evil doers, in consequence of this, Vishnu, on
the seventh of Bhadun, in the Shakl pachah, or “bright half of the
moon,” assumed the Avátar of Parasúram, who was of the seed of
the Brahmans. In this incarnation he exterminated the Chettri class
so utterly, that he even ripped open their females and slew the
fœtus. According to the Hindus, Parasuram is always living; they call
him Chirangivah, or “long-lived.”
The seventh is the Ram Avátar:[48] when the tyranny of the
Rakshas Rávana, sovereign of the demons, had exceeded all bounds,
Vishnu, on the ninth of Chet in the Shaklpachah, becoming incarnate
in Rama, who was of the Chettri caste, overthrew at that time
Rávána, chief of the demons of Lanka, (Ceylon). Now Lanka is a fort
built of golden ingots, situated in the midst of the salt ocean. He
also recovered Sita,[49] the wife of Rama, who had had been taken
away by the Rokshas, which is a name given by the Hindoos to a
frightful demon.
The eighth was the Krishn Avátar. When Vishnu, in the Dwapar-
Jog, on the eighth of Bhádún, in the Kishn pachah, having assumed
the Avátar of Krishna, slew Kansá. Krishna was also of the Chettri or
“military caste.”
The ninth was the Budh avatar. When ten years only of the
Dwapar-Jog remained,[50] Vishnu, in order to destroy the demons
and evil genii, the causers of night, assumed the Avátar of Buddha,
on the third of Baisakh, in the Shakl pacheh.
The tenth Avátar is to occur at the expiration of the Kali-jug, for
the purpose of destroying the Mlechas, or “enemies of the Hindoos.”
The Kalki Avátar is to take place on the third of Bhádún, in the Shakl
Pachah, in the city of Sumbul, in the house of a Brahman named
Jasa. Kalki is also to be of the Brahman caste. He will destroy the
corruptions of the world, and all the Mlechas, that is,
Muhammedans, Christians, Jews, and such like, are to be entirely
extirpated: after which the Satyog, or “golden age,” is to return.
They moreover maintain, that the contingently-existing
inhabitants and beings of earth are unable to penetrate into the
presence of the necessarily-existing sovereign, and that the essence
of the Creator is too exalted for any created beings to attain to an
acquaintance with it, notwithstanding the high knowledge and piety
with which they may be adorned: it therefore seemed necessary to
the Almighty God to descend from the majesty of abstractedness
and absolute existence, and exhibit himself in the various species of
angels, animals, man, and such like, so as to enable them to attain
to some knowledge of himself. They therefore assert, that for the
purpose of satisfying the wishes of his faithful servants, and
tranquillizing their minds, he has vouchsafed to manifest himself in
this abode, which manifestation they call an Avátar and hold this to
be no degradation to his essence. This tenet has been thus
interpreted by Shidosh, the son of Anosh: According to the Súfís, the
first wisdom is the knowledge of God, and of the universal soul, his
life; and in this place they have expatiated upon the attributes of the
Almighty; thus by Brahma they mean his creative power; and by the
old age of Brahma is implied his perfection: philosophers also call
the first intelligence, the intellectual Adam, and the universal soul,
the intellectual Eve. The sage Sunai has said:
“The father and the mother of this gratifying world,
Know, is the soul of the word,[51] and the sublime wisdom.”

By Vishnu is meant his attribute of divine love, and also the


universal soul; and they give the name of Avátar to the spirit derived
from the soul of the first heaven; in which sense they have said:
“Avátars are rays issuing from Vishnu’s essence.”
But these sectaries do not mean that the identical spirit of Rám,
on the dissolution of its connection with his body, becomes attached
to the body of Krishna; for they themselves assert that Parsurám
(the sixth Avátar) is immortal, and his body everlasting.
When Rámachandra became incarnate, he encountered the other;
and Parsurám, having posted himself on the road with hostile
intentions, Rámachandra said: “Thou art a Brahman and I a Chettri:
it is incumbent on me to show thee respect:” then applying the horn
of his bow to Parsurám’s foot, he deprived him of all power. When
Parsurám who is now along with his wife in the heavens, enrolled
among the stars: he was the instructor of Rama, and brought him to
the knowledge of himself; and his counsels to Ráma have been
collected by the Rishi Valmiki in the History of Ráma, called the
Ramáyana, and the name of Jog-Vashishta, given to them, which
they call Indrazaharájóg Vashishta.[54] Some parts of these tales
were selected by a Brahman of Kashmir, and afterwards translated
into Persian by Mulla Muhammed, a Súfí. To resume: Ráma, on
hearing this expression from Parsurám, said: “My arrow, however,
errs not:” he then discharged some arrows which have become the
janitors of paradise, and do not permit Parsurám to enter therein.
This parable proves that they are by no means taken for Avátars of
Naryáan; as, although Pursurám and Rám were two Avátárs of
Vishnu, yet they knew not each other. Again, it is an established
maxim among philosophers, that one soul cannot be united in one
place with two distinct bodies. Besides, it is certain that they give
the name “Avatárs of Naráyan” to the souls which emanate from the
universal soul; and that they call Naráyan the soul of the empyreal,
or the fourth heaven. As to their assertions that Naráyan is God,
found himself destitute of strength, he asked his name, and on
learning that it was Ramachandra, he was greatly astonished, and
said: “Has Rámachandra’s Avátar taken place?” and Rámachandra
having replied “Certainly,” Parsurám said: “My blow is not mortal, I
have taken away thy understanding.” On this account it happened
that Rámachandra possessed not intelligence in his essence, and
was unacquainted with his true state, wherefore they style him the
Mudgha, or stupid Avátar.[52]
Vasishta, one of the Rishies,[53] or “holy sages,” and their
acknowledging his Avátars as God, and their saying that the
Almighty has deigned to appear under certain forms, all this means
that a Naráyan is the same with the universal soul, which the Súfees
entitle “the life of God.” As life is an attribute of the Almighty, and
the perfection of attributes constitutes his holy essence,
consequently the souls which emanate from the universal soul, or
that of the empyreal heaven, which is the life of God, know
themselves, and acquire the ornaments of pure faith and good
works; and also, on being liberated from body, they become
identified with the universal soul, which is Vishnu, or the life of God,
agreeably to this saying: “He who knows his own soul, knows God:”
that is, he becomes God.
As to their acknowledging the fish, tortoise, and boar to be
incarnations of the divinity, by this they mean, that all beings are
rays emanating from the essence of the Almighty, and that no
degradation results to him therefrom, according to this narration of
the Mir Sáíd Sharif, of Jarjan (Georgia).
As a Súfí and rhetorician were one day disputing, the latter said:
“I feel pain at the idea of a God who manifests himself in a dog or
hog:” to which the Súfee replied: “I appeal from the God who
displays not himself in the dog.” On this, all present exclaimed: “One
of these two must be an infidel.” A man of enlightened piety drew
near, and showing them the exact import of these expressions, said:
“According to the belief of the rhetorician, the dignity of God is
impaired by his manifesting himself in the dog; he is therefore
distressed at the idea of a God thus deficient. But, according to the
Súfee, the non-appearance of God in that animal would be a
diminution of his dignity, he therefore appeals against a God
deficient in this point: consequently, neither of them is an infidel.” So
that, in fact, the Súfís and these sectaries entertain the same
opinions.
The author of this work once said to Shídósh: “We may affirm
that by the fish is meant the lord, or conservative angel, of water;”
as, according to their mythology, a demon having taken the Vedas
under that element, was pursued and slain by Vishnu, and the Vedas
brought back: thus their mention of a fish originated from its
inseparable connection with water. By the tortoise is meant the lord,
or conservative angel, of earth; as their mythology relates, that the
Avátar of the tortoise occurred for the purpose of the earth being
supported on its back, as is actually the case; they have also
especially mentioned the tortoise, as it is both a land and aquatic
creature, and that after water comes earth. By the boar are meant
the passions and the propagation of living creatures; and as to the
tradition of a demon having stolen away the earth and taken it under
the water, and of his being pursued by Vishnu under the form of a
boar, and slain by his tusks, its import is as follows: the demon
means dissolute manners, which destroyed the earth with the deluge
of sensuality; but on the aid of the spirit coming, the demon of
dissoluteness was overthrown by the tusks of continence: the boar is
particularly mentioned, because its attribute is sensuality; and it was
reckoned an Avátár, because continence is virtue. The Narsinh, or
“man-lion,” is the lord, or conservative angel of heroism; and as this
constitutes a most praiseworthy quality, they said, that the Narsinh
was a form with a lion’s head and a human body, for when they
spoke of impetuous bravery in a man, they made use of the term
“lion.” By Vámana, or “dwarfish stature,” they meant, the lord of
reason, strength of reflection, and an intellectual being; the dwarfish
stature implying that, notwithstanding a diminutive person,
important results may be obtained through him; as in almost a direct
allusion to this, people say: “An intelligent man of small stature is far
superior to the tall blockhead.” By Rajah Bali, they typify generosity
and liberality.
Shidósh was delighted at this interpretation, and said: “They have
also recorded that Krishna had sixteen thousand wives; and when
one of his friends who thought it impossible for Krishna to visit all of
them, said to try him: ‘Bestow on me one of thy wives,’ Krishna
answered: ‘In whatever female’s apartment thou findest me not, she
is thine.’ His friend went into the different apartments, but in every
one of them he beheld the god engaged in conversation with its
mistress.” This story implies, that the love of Krishna was so rooted
in their hearts, that they cared for none besides, having his image
present to their eyes, and dwelling every moment on his beloved
idea.
The tradition of Vishnu’s always bearing the Chakra in his hand (a
kind of military weapon), alludes to the knowledge and decisive
demonstration which are unattainable without the aid of soul.
In Mahadeo, they allude to our elementary nature by the serpent
twined round his neck; they mean anger, and the other
reprehensible qualities which result from corporeity; by his being
mounted on a bull, the animal propensities; by the tradition of his
place of repose being the site for burning the dead, is signified, the
total dispersion of the particles of bodies and the perishable nature
of things. Mahadeo’s drinking poison is also to the same purport. In
this sense they also say that Mahadeo is the destroyer of all worldly
things; that is, elemental nature imperatively requires the dissolution
of combination (connection), and that ultimately death comes in the
natural course.
They also hold that every angel has a wife (female energy), of a
similar generic constitution, and originally derived from Brahma; and
as we have before stated, the philosophers call the first intelligence
the True Sire, and the universal soul, Eve; and thus he is the head
and the wife the shoulder; the universal soul is the body of the
empyreal heaven; and in like manner the other celestial souls and
bodies have wives of the elementary nature; as they give the
appellation of wife, or energy, to whatever is the manifest source of
action.
Moreover the established doctrine held by these sectaries is, that
each class should worship a particular angel, and the wife or female
energy of that angel; the worshipper regarding the object of his
adoration as God, and all others, as created beings; for example,
many believe Naráyan to be the supreme God; several others, look
up to Mahadéo, and many to the other male and female divinities;
and thus, pursuant to the four Védas, which according to their
common belief are a celestial revelation, they do not hold any angel
who is the object of their praise as distinct from God: by which they
mean that God, who is without equal, having manifested himself
under innumerable modes of appearance, contemplates the glorious
perfection of his essence in the mirrors of his attributes; so that,
from the most minute atom to the solar orb, his holy and divine
essence is the source of all that exists.
“To whatever quarter I directed my sight, thou appearedst there;
How widely art thou multiplied, even when thy features are unseen!”

The Fakir Arzú says: the above interpretation is confirmed by this


tradition of the Hindus, that Agasti,[55] a star, was formerly a holy
man, who once collected all the waters in the palm of his hand, and
swallowed the whole; which means that Agasti is the same as
Sohail, a star adjacent to the south pole, on the rising of which, all
the water that has fallen from heaven is dried up, agreeably to the
Arabic saying:
“When Suhail ascends, the torrents subside.”

Many enigmatical and figurative expressions of a similar


description occur in their writings; for example, Mahésh or Mahadeo,
is an angel with matted locks and three eyes, which are the sun,
moon, and fire; he has also five heads; his necklace is formed of a
serpent, and his mantle of an elephant’s hide. There are nine
Brahmas, eleven Rudras or Mahadeos, twelve suns, and ten regions,
viz.: east, west, south, north, zenith, Nadir, Akni, “between east and
south;” Níreti, “between south and west;” Dayab, “between west
and north;” and Isan, “between north and east.” The angels are in
number thirty-three Kotes, or three hundred and thirty millions, each
Kote consisting of one hundred Laks, or ten millions. These angels
have spiritual wives, who produce a spiritual offspring. They likewise
hold human spirits to be an effulgence proceeding from the divine
essence; if to knowledge they add good works, with a clear
perception of themselves and of God, they return to their original
source; but should they not know themselves and God, and yet
perform praiseworthy acts, they dwell in Paradise, where they
remain during a period of time proportioned to their meritorious
works; on the expiration of which period they are again sent down
to this lower world, and again to receive a recompense proportioned
to their deeds.
The actions even of the inhabitants of Paradise undergo an
investigation, and are attended with reward or punishments duly
graduated. They also hold that all those persons who are not
sufficiently worthy of entering into paradise, but who have observed
religious ordinances in order to obtain dominion and worldly
enjoyments, shall acquire their object in a future generation. They
also say, in respect to any great personage, in whose presence the
people stand girt with the cincture of obedience, that the rewards
and results are, that this person continues in a suppliant attitude
devoted to the service of God and those individuals who prostrate
themselves before him, are in fact humbling themselves in adoration
of the Almighty; in short, they hold all splendor and greatness as the
rewards of alms and good works; thus they relate that whilst the
incarnation of Rámchandra abode in the desert, he sent his brother
Lachman to bring some roots of herbs in order to break his fast; but,
notwithstanding a diligent search, he being unable to find any,
returned and represented this to Rámchand, who replied: “The earth
abounds in food and drink; but in a former generation, on this very
day, I omitted the performance of an act which would have been
well pleasing in the sight of God, namely, that of contributing to the
sustenance of indigent Brahmans.”
They moreover believe that evil-doers, after death, become
united to the bodies of lions, tigers, wolves, dogs, swine, bears,
reptiles, plants, and minerals, in this world, and receive under these
forms their well merited punishment; but that those who have been
guilty of aggravated crimes are hurried off to the infernal regions,
where they remain suffering torture during a period of time
proportioned to their evil deeds; and when they have undergone the
destined punishment, they again return to this world. They also
believe that there is in paradise a sovereign, named Indra, and that
whoever offers up a hundred Aswamédas,[56] becomes Indra. When
his appointed time in paradise, in the full enjoyment of sovereign
power has passed, he is on the expiration of that period to descend
to the lower world, and there obtains a recompense proportioned to
his acts. Moreover, Indra’s spouse is named Sachí Devi, and falls to
the share of the person who attains the rank of Indra. Note: by
Aswaméda is meant the sacrifice of a horse of a certain color, and
according to certain established rites. However, by Aswaméd, their
learned doctors understand “abnegation of the mind:” for
imagination is a fierce charger, the sacrifice of which is an imperative
duty on the religious ascetic; or it may allude to the destruction of
the animal passions.
They also believe that angelic beings are subject to
concupiscence, and wrath, and the cravings of hunger and thirst;
their food consisting of perfumes and incense, sacrifices, meat and
drink offerings, with the alms and oblations made by mankind; and
their beverage, the water of life.
They also assert that the stars were holy personages, who, on
leaving this world of gloom, through the efficacy of religious
mortifications became luminous bodies, ascending from the lower
depths of this abode of the elements to the zenith of the crystalline
sphere; nay, their birth-place, name, family, with the names of their
fathers and grandfathers, are carefully enumerated in the sacred
volumes of this sect. Thus they say that Sanicher (the slow-traveller)
or Saturn, is the son of the glorious Luminary; and Mirrikh or Mars,
the son of the Earth; the world-enlightening sun, the issue of
Kashyapa, the son of Maríchí, the son of Brahma; Zóhrah (or the
regent of Venus) the son of Bhrigu; and Utáred (Mercury) the son of
Kamer (the regent of the moon). Some however maintain the moon
to be the son of Attri the Holy, but, according to others he is sprung
from the sea of milk.
[57]
*These opinions contain a marked allusion to the tenets held
by the distinguished Parsi sages, namely, that the intellectual soul
has a relation to that sphere with which its good actions are
connected: they consequently apply the denomination of Sun to the
spirit of one united to the sun, and his father is entitled “the father
of the Sun.”*
The writer of this work once observed to Shídósh, the son of
Anosh: “Perhaps they mean by the sires of the stars, their presiding
intelligences, as in the technical language of philosophers, the name
of sires is also given to the intelligences, on which account Jesus
called the Almighty ‘Father.’”
According to them the elements are five in number, the fifth being
the Akas (or ether), which word in its common acceptation means
“the heavens;” but according to the learned it implies empty space,
or space void of matter. One of their distinguished doctors, Sumitra,
son of the Ray of Kalinga, holds that Akas, which the Greek
Platonists call space, is simple and uncompounded. Damudar Das
Kaul, a learned Brahman of Kashmir, also holds Akas to signify
space; and space is understood by the Platonists among the Yonian
to be an extent void of any substance (a vacuum), which may be
divided into parts, the totality of which parts may be equivalent to
that extent of the general vacuum which is congruous and equal to
it, in such a manner as to comprise every particle of that extent
which is the space in every particular division of the general space.
There is an extent interposed between two things, and this extent is
void and free of matter. According to their account, no better
interpretation of Akas than that which is conveyed by the word
space, can be offered.[58]
They moreover assert that the heavens have no existence, and
that the constellations and stars are fixed in the air. According to
them there are seven samudras, that is oceans, on this earth: the
salt sea, that of sugar-cane juice, the sea of spirituous liquors, that
of clarified butter, the sea of curds, the lacteal, and lastly, that of
sweet waters. They also say that there rises above the earth a
mountain called Su-Meru[59] entirely formed of the purest gold, on
which the angelic beings reside, and around which the stars revolve.
There are nine spheres, namely: those of the seven planets, with
those of Rás and Zanab (the head and tail of the dragon), which are
also borne along in their celestial vehicles. Rás and Zanab are two
demons who drank the water of life, whom Vishnu, at the suggestion
of the sun and moon, smote with a weapon called the Chákra, or
disk, and rent open their throats; in revenge for which, the moon is
devoured by Rás, and the sun by Zanab; but as their throats are rent
open, whatever is taken in at the mouth issues at the aperture in the
throat: by this allegory they allude to the lunar and solar eclipses.[60]
Brahma dwells in a city called Rást Lok;[61] Vishnu in a region
called Vaikanth; and Mahadeo on a mountain of silver named
Káilasa. They also maintain that the fixed stars have no actual
existence, but that the objects which shine by night are couches of
gold set with diamonds and rubies, on which the inhabitants of
paradise repose. [62]*On this Shidosh remarks: “It is agreed that
paradise means the heavens, and also that the fixed stars are in the
eighth heaven; so that, consequently, the heavens constitute the
couches of the souls.”*[63]
They esteem the majesty of the great light as the supreme of
angelic beings, and on a careful investigation of their books,
acknowledge no existence as superior to him in dignity; as the
constitution of elemental compounds, and the existence of all beings
is dependent on and connected with his auspicious essence. They
moreover regard Brahma, Vishnu, and Mahesh, the radiance and
reflexion of his light; saying, it is his majesty alone which, by its acts
and operations, is called by these three names. They represent him
as a sovereign, in the human form, seated in a chariot which
signifies the fourth heaven, to which are attached seven horses, with
angels and spiritual beings, accompanied by royal trains and
gorgeous pomp, continually passing before his majesty. They also
esteem him as the source of existence and as universal existence.
*They also believe the earth to be the skin of a Raksh or evil genius,
who was put to death, and his skin stretched out: the mountains are
his bones; the waters his blood; the trees and vegetables his hair. By
Raksh they mean a demon, which here implies the material elements
on this earth, which according to them is supported on four legs;
alluding in this to the nature and number of the elements, each of
which rests on its own centre.
According to them Saturn limps, which typifies his long period of
revolution; and Bhúm, or Maríkh, “Mars,” is a demon, on which
account they ascribe to him a malignant influence.* Zoharah, or “the
regent of Venus,” is the director of the demons, and to this planetary
spirit they ascribe the sciences and religions of the barbarians, and
the creeds of foreign nations.
The Muhammedan doctors say, that Islamism is connected with
this planet, from which source proceeds the veneration paid by them
to Friday, or the day of Venus. Múshteri, “Jupiter,” is accounted the
director of the angels, and the teacher of the system of Brahma,
which is conveyed in a celestial language, not used at present by
any beings of elemental formation: thus, although the Koran is a
divine revelation, the language of it is in general use among the
Arabs; but the four Véds which the Hindus account a celestial
volume, is written in Sanskrit, a language spoken in no city
whatever, and found in no book, save those of a particular sect: it is
called by them “the speech of angelic beings.” The Véda was given
to them by Brahma, for the due arrangement of human concerns. By
angels or divine beings, they mean eloquent speakers, and learned
authors, who, being illuminated by the effulgence of primitive
wisdom, interpreted whatever was revealed to them. It is to be
remarked, that every one who pleases may derive from the Védas
arguments in favour of his particular creed, to such a degree, that
they can support by clear proofs the philosophical, mystical,
unitarian, and atheistical systems, faith, and religion; Hinduism,
Judaism, Christianity, fire-worship, the tenets of the Sonites, or those
of the Shíâs, etc.; in short, these volumes consist of such ingenious
parables and sublime meanings, that all who seek may have their
wishes fulfilled.
They say that the Almighty is a great body, and that all other
beings are in his belly; which resembles the opinions maintained by
the venerable Shaikh Shahbáb ud deen Maktúl, whose tomb may
God sanctify! namely, that the universe is one body, which contains
all others in existence, and is called the universal body. It has one
spirit, which comprehends all others, and is called the universal soul;
and one single object of intelligence, from which they derive all
intelligences, calling it the universal intelligence. It is stated in the
Mujmal al Hikmat, or Compendium of Philosophy, that the Almighty
is the spirit of spirit; and according to Azar Húshangian, “the intellect
of intellect.” Shaikh Bó Ali[64] (whose place of repose may God
illuminate!) thus speaks:
“The Almighty is the soul of the universe, and the universe the reunion of all
bodies;
The different angelic hosts are the senses of this frame;
The bodies, the elements, and the three kingdoms are its members;
All these are comprehended in the divine unity; all other things are illusion.”

This sect gives the appellation of Rakshas, which means evil genii
or demons, to all those who do not profess their faith, and who
perform not good works.
Time, in Hindawi Kal, is a measure of the movement of the great
sphere, according to the philosophers of Greece and Persia. The
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebookgate.com

You might also like