Murach S Java Servlets and JSP 3rd Edition Edition Joel Murach Download
Murach S Java Servlets and JSP 3rd Edition Edition Joel Murach Download
https://ebookgate.com/product/murach-s-java-servlets-and-jsp-3rd-
edition-edition-joel-murach/
https://ebookgate.com/product/murach-s-java-se-6-1st-ed-edition-joel-
murach/
ebookgate.com
https://ebookgate.com/product/murach-s-c-2010-4th-edition-joel-murach/
ebookgate.com
https://ebookgate.com/product/murach-s-html5-and-css3-3rd-edition-
anne-boehm/
ebookgate.com
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
https://ebookgate.com/product/murach-s-sql-server-2012-for-
developers-1st-edition-bryan-syverson/
ebookgate.com
https://ebookgate.com/product/developing-java-servlets-2nd-edition-
james-goodwill/
ebookgate.com
https://ebookgate.com/product/murach-s-ado-net-4-database-programming-
with-vb-2010-4th-edition-anne-boehm/
ebookgate.com
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
10 9 8 7 6 5 4 3 2 1
ISBN-13: 978-1-890774-78-3
Content
Introduction
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 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.
• 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.
Joel Murach
Author
ection
--
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
"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
Qty Description
Internet
- connection
- I
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.
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.
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.
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
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.
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.
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).
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
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.
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
File Edit View Navigate Source Re-factor Run Debug Profile Team Tools Window Help IQ.• Search (Ctrl+I)
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
�1 rrr J
17:36 I INS
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.
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.
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
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
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
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
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
Language: English
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;
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 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.
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