Murach s Java Servlets and JSP 3rd Edition Edition Joel Murach - Quickly access the ebook and start reading today
Murach s Java Servlets and JSP 3rd Edition Edition Joel Murach - Quickly access the ebook and start reading today
com
https://ebookgate.com/product/murach-s-java-servlets-and-
jsp-3rd-edition-edition-joel-murach/
OR CLICK BUTTON
DOWLOAD EBOOK
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
Author: S. H. Crittenden
Language: English
A LECTURE
DELIVERED
BEFORE THE STUDENTS
OF
CRITTENDEN’S
Philadelphia Commercial College,
BY
S. H. CRITTENDEN,
Attorney at Law,
CONSULTING ACCOUNTANT AND PRINCIPAL.
PHILADELPHIA:
RINGWALT & BROWN, STEAM-POWER BOOK AND
JOB PRINTERS,
Nos. 111 & 113 SOUTH FOURTH STREET.
1863.
USURY:
OR
A LECTURE[A]
TRANSCRIBER’S NOTES:
Obvious typographical errors have been corrected.
Archaic or alternate spelling has been retained from the original.
*** END OF THE PROJECT GUTENBERG EBOOK USURY; OR,
INTEREST, PREMIUM AND DISCOUNT ***
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
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