simplyjava1_29 - Com Sci Gate

judgedrunkshipΔιακομιστές

17 Νοε 2013 (πριν από 4 χρόνια και 1 μήνα)

108 εμφανίσεις

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


1

Outline

29.1

Multi
-
Tier Architecture

29.2

Web Servers

29.3

Apache Tomcat Web Server

29.4

Test
-
Driving the
Bookstore

Application

29.5

Wrap
-
Up

Tutorial 29


Bookstore Application:
Web Applications

Introducing Apache Tomcat Web Server

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


2

Objectives


In this tutorial, you will learn to:


Use the Apache Tomcat Web server to serve Web content to
Web browser clients.


Request documents from a Web server.


Execute a Web application that uses Java Server Pages
technology.


© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


3

29.1 Multi
-
Tier Architecture


Web applications


Java Server Pages JSP


HTML (HyperText Markup Language)


Multi
-
Tier applications


n
-
tier applications


Tier


Information tier


Data tier, bottom tier


Middle tier


Business logic tier


Client tier


Top tier

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


4

29.1 Multi
-
Tier Architecture (Cont.)

App licat ion
Midd le t ier
Inf ormat ion t ier
Client t ier
Da ta ba se
Figure 29.1

Three
-
tier application model
.

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


5

29.2 Web Servers


Web Server


URL (Uniform Resource Locator)


Host


Domain


Domain name (Web address)


Fully qualified domain name (FQDN)


Top
-
level domain (TLD)


IP (Internet Protocol) address


Domain Name System (DNS) server


DNS Lookup

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


6

29.3 Apache Tomcat Web Server

Figure 29.2

Locating the Java Development Kit
. Copyright © 2000
-
2003 The Apache
Software Foundation (
http://www.apache.org/
). All rights reserved.

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


7

29.3 Apache Tomcat Web Server (Cont.)

Figure 29.3

Accepting the Tomcat license agreement
. Copyright © 2000
-
2003 The Apache
Software Foundation (
http://www.apache.org/
). All rights reserved.

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


8

29.3 Apache Tomcat Web Server (Cont.)

Figure 29.4

Accepting Tomcat default installation options
. Copyright © 2000
-
2003 The
Apache Software Foundation (
http://www.apache.org/
). All rights reserved.

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


9

29.3 Apache Tomcat Web Server (Cont.)

Figure 29.5

Choosing the default Tomcat installation directory
. Copyright © 2000
-
2003 The
Apache Software Foundation (
http://www.apache.org/
). All rights reserved.

Tomcat installation
default directory

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


10

29.3 Apache Tomcat Web Server (Cont.)

Figure 29.6

Tomcat installation process dialog
. Copyright © 2000
-
2003 The Apache
Software Foundation (
http://www.apache.org/
). All rights reserved.

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


11

29.3 Apache Tomcat Web Server (Cont.)

Figure 29.7

Selecting a Tomcat administrator password
. Copyright © 2000
-
2003 The
Apache Software Foundation (
http://www.apache.org/
). All rights reserved.

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


12

29.3 Apache Tomcat Web Server (Cont.)

Figure 29.8

Completing the Tomcat installation
. Copyright © 2000
-
2003 The Apache
Software Foundation (
http://www.apache.org/
). All rights reserved.

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


13

29.3 Apache Tomcat Web Server (Cont.)


Copy the
C:
\
Examples
\
Tutorial29
\

CompletedApplication
\
bookstore

directory to
Tomcat’s
webapps

directory

Figure 29.9

Copying the
bookstore

folder to
webapps
.

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


14

29.3 Apache Tomcat Web Server (Cont.)

Figure 29.10

Copying the database JAR files to the
Bookstore

Web application
.

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


15

29.4 Test
-
Driving the
Bookstore

Application

Application Requirements

A bookstore employee receives e
-
mails from customers asking for information pertaining
to the books the store sells online. The employee has asked you to create a three
-
tier
Web application that allows users to view online informa
tion about various books. This
information includes the author, cover image, price, ISBN number, edition number,
copyright year and a brief description of the book. The Bookstore application you create
will use JavaServer Pages to implement the middle tier
. The client tier will create the
application’s GUI, which will be implemented using HTML. The application’s GUI
should allow users to select a book title and view the information about the selected
book. The middle tier will retrieve the book information
from the information tier and
display it in the client tier. The information tier will maintain the database, which has
been created using Cloudscape. You will use the JDBC API to access the database,
which will be provided to you
.



© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


16

29.4 Test
-
Driving the
Bookstore

Application
(Cont.)

Figure 29.11

Tomcat server output window
.

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


17

29.4 Test
-
Driving the
Bookstore

Application
(Cont.)

Figure 29.12

HTML page that displays a form, with a list and a button
.

HTML page title

Location of
books.jsp

page

HTML
h1

header element

HTML paragraph element

HTML menu control
used to display a list

HTML
input

element
with type
submit

used to
display a button

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


18

29.4 Test
-
Driving the
Bookstore

Application
(Cont.)

Figure 29.13

Page that displays the selected books information.

Address of
bookInformation.jsp

page

When clicked, this link
returns users to
books.jsp

© Copyright 1992
-
2004 by Deitel & Associates, Inc. and Pearson
Education Inc. All Rights Reserved.


19

29.4 Test
-
Driving the
Bookstore

Application

Figure 29.14

Deleting the
bookstore

folder from Tomcats
webapps

folder
.

Right click
bookstore

Select
delete