29 T U T O R I A L 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. Outline 29.1 Multi-Tier Architecture 29.2 Web Servers 29.3 Apache Tomcat Web Server 29.4 Test-Driving the Bookstore Web Application 29.5 Wrap-Up Bookstore Web Application Introducing Web Applications and the Apache Tomcat Web Server I nprevious tutorials, you used Java to develop desktop applications. Each application contained agui with which the user interacted. You can also use Java to create Webapplications.These applications,also known as Web-based applications,can use JavaServer Pages (JSP) technology to create Webcontent data that can be viewed in aweb browser, such as Internet Explorer (from Microsoft) or Netscape (from Netscape Communications Corporation). This Web content includes HTML ( HyperText Markup Language) documents and images.jsp uses Java and HTML to develop dynamic Webpages.HTML is alan- guage that is understood by virtually all Webbrowsers and used to publish online documents with GUI elements, text and images. With HTML, you can create Webpages that can access other online documents using hypertext links,and you can design forms (containing components similar to JComboBox, JTextField and JButton) to obtain user input. You will learn the HTML you need to build your Bookstore Webapplication in Tutorial 30. In Tutorial 29, you will learn the multi-tier architecture that is used to create Webapplications.You will learn about Web servers and install the Apache Tomcat Web server, which you will need to run your Bookstore Webapplication. You will learn important Webdevelopment concepts in the context of the Bookstore Webapplication. This application consists of two Webpages. The first page displays alist of books. After selecting abook, the user clicks abutton that directs the browser to a second Webpage. Information about the selected book is then retrieved from adatabase and displayed on the second Webpage.This page contains alink that, when clicked, directs the Web browser back to the first Web page, allowing the user to select adifferent book. Before you create this Web application, you will learn fundamental Web development concepts that are required to understand the Bookstore Webapplication, which you will then testdrive.intutorial 30 Tutorial 32, you will analyze the pseudocode and ACE table for the Bookstore Web application and you will implement the application in Java using the most advanced techniques you have learned in this book. 842
Tutorial 29 Bookstore Web Application 843 29.1 Multi-Tier Architecture Webapplications are multi-tier applications, sometimes referred to as n -tier applications. Multi-tier applications divide their functionality across separate tiers (that is, logical groupings of functionality). The tiers of an application can be located on the same computer or on separate computers distributed across a network most commonly, the Internet. In this case study, you will implement all three tiers on one computer. Figure 29.1 illustrates the basic structure of a multi-tier application. An explanation of each tier follows the figure. Client tier Middle tier Application Information tier Database Figure 29.1 Three-tier application model. The information tier (also called the data tier or the bottom tier) maintains the data for the application. For example, the information tier for the Bookstore Web application is implemented as adatabase that contains product information, such as book titles,author names,publication dates,edition numbers,isbn numbers,book descriptions and prices. The middle tier controls the interactions between application clients (such as Webbrowsers) and application data in the information tier.in the Bookstore Web application, the middle-tier code determines which book was selected by the user and retrieves the information for that book from the database.the middle tier also determines the format in which the selected book s data will be displayed. Thus, the middle tier represents the functionality of the Webapplication and is often called the business logic tier. The client tier,or top tier,is the application s user interface, which is typically a Web browser.the user will interact directly with your application through the client tier (browser) by entering text, selecting from lists, clicking buttons, etc. The browser reports the user s actions and data entered to the middle tier, which processes the information. The middle tier can also make requests to,and retrieve data from, the information tier. The client Web browser then displays to the user the data retrieved by the middle tier from the information tier. SELF-REVIEW 1. The information tier is also called the tier in a typical three-tier application. a) top b) middle c) bottom d) client
844 Introducing Web Applications and the Apache Tomcat Web Server Tutorial 29 2. In a typical three-tier application, the role of the middle tier is to. a) control the interaction between the client and information tiers Answers: 1) c. 2) a. 29.2 Web Servers A Web server is specialized software that responds to client (Web browser) requests by providing requested resources (such as HTML documents and access to databases). To request documents from Web servers, users must know the addresses at which those documents reside.a URL ( Uniform Resource Locator) can be thought of as an address that is used to direct a Web browser to a resource on the Web. A URL contains the protocol of the resource (such as http), the machine name or IP address for the resource (we will discuss machine names and IP addresses shortly) and the name (including the path) of the resource.for example,in the URL http://www.deitel.com/index.html b) control the interaction between the client and the user interface c) display the application s user interface d) provide adatabase for the application the protocol is http, the machine name is www.deitel.com and the name of the resource is index.html. Once the Bookstore Webapplication is properly set up, users can run it by typing its URL into aweb browser.this action is translated into a request to the Web server (such as Apache Tomcat) where the Bookstore Web application resides. When the user interacts with the Web browser to request information from the Bookstore Web application, the Web server retrieves information from the information tier (contains the Cloudscape database) and sends Web content created by the Bookstore Webapplication back to the client Webbrowser, which displays that content for the user.for example, when a user sends a request to view all the book titles by selecting a title and clicking the button, the Web content created by the Bookstore Web application will include a list of book titles and a button. When a user sends arequest for viewing book information for aspecific book, the Webcontent created by the Bookstore Webapplication will include information (such as author, price, ISBN number, edition number, copyright year and description) about the book the user selected. You will install the Apache Tomcat Web server and the Bookstore Webapplication in the next section. To understand how aweb browser is able to locate documents on aweb server, it is helpful for you to know the following terms: 1. Host: A host is a computer that stores and maintains resources, such as Webpages,databases and multimedia files.in the case of the Bookstore Web application, the host is your computer, because all the applicationrelated resources,including JSPs and databases,are stored in your computer. 2. Domain: A domain represents agroup of hosts on the Internet. Each domain has a domain name, also known as a Web address, which uniquely identifies the location of a business or organization on the Internet. 3. Fully qualified domain name: A fully qualified domain name (FQDN), also known as the machine name, contains a host (for example, www for World Wide Web) and a domain name, including a top-level domain ( TLD). The top-level domain is the last and most significant component of afully qualified domain name. To request documents from the Web server, users must know the fully qualified domain names (machine names) on which the Web server software resides. For example, to access the documents from Deitel s Web server, you must know the FQDN www.deitel.com. The FQDN www.deitel.com indicates that the host is
Tutorial 29 Bookstore Web Application 845 www and the top-level domain is com.inafqdn, the TLD often describes the type of organization that owns the domain. For example, the com TLD usually refers to a commercial business, the org TLD usually refers to a nonprofit organization and the edu TLD usually refers to an educational institution. In addition, each country has its own TLD, such as cn for China, et for Ethiopia, om for Oman and us for the United States. Each FQDN corresponds to anumeric address called an IP ( Internet Protocol) address, which is much like the street address of a house. Just as people use street addresses to locate houses or businesses in a city, computers use IP addresses to locate other computers on the Internet. Each internet host computer has a unique IP address.each address is comprised of four sets of numbers separated by periods, such as 63.110.43.82.ADomain Name System ( DNS) server is a computer that maintains a database of FQDNs and their corresponding IP addresses.the process of translating FQDNs to IP addresses is called a DNS lookup. For example, to access the Deitel Web site, type the FQDN www.deitel.com into aweb browser. The DNS lookup translates www.deitel.com into the IP address of the Deitel Web server ( 63.110.43.82). In the next section, you will install the Apache Tomcat Web server and the completed Bookstore Webapplication. SELF-REVIEW 1. A(n) is a computer that stores and maintains resources. a) host b) IP address c) domain name d) Domain Name System 2. ADNS lookup is a. a) translation of an IP address to adomain name c) translation of afully qualified domain name to ahost name Answers: 1) a. 2) b. 29.3 Apache Tomcat Web Server b) translation of afully qualified domain name to an IP address d) search for a domain name The Apache Group s Tomcat is the Web server you will use to create and deliver Web pages to clients in response to client requests. Before you can test-drive the completed application, you must install Tomcat and the Bookstore Web application. You must have the Java 2 Software Development Kit (J2SDK) v1.4 installed before you install Tomcat. [ Note:You already have J2SDK v1.4 installed if you have been running and building the applications in this book. If you already have the Tomcat installed, you can skip this step.] Installing Tomcat and the Bookstore Web Application 1. Installing Tomcat. Locate the jakarta-tomcat-4.1.24-le-jdk14.exe file on the CD (in the software\windows\tomcat directory) and double click it to run the installer program, which will install Tomcat step-by-step. 2. Confirming the location of your Java Development Kit installation. The Tomcat installer will locate your J2SDK installation directory automatically. In the first dialog box (Fig.29.2), click OK toconfirm the installation directory of J2SDK version 1.4. Figure 29.2 Locating the Java Development Kit. Copyright 2000 2003 The Apache Software Foundation ( http://www.apache.org). All rights reserved.
846 Introducing Web Applications and the Apache Tomcat Web Server Tutorial 29 (cont.) 3. Accepting the license agreement. To install Apache Tomcat, you must accept the license agreement. When prompted with the license agreement, read it carefully and, if the terms are acceptable to you, click IAgree (Fig.29.3). Figure 29.3 Accepting the Tomcat license agreement. Copyright 2000 2003 The Apache Software Foundation ( http://www.apache.org). All rights reserved. 4. Accepting the default installation options. When prompted to choose the type of installation to perform, click Next to accept the default options (Fig.29.4). Figure 29.4 Accepting Tomcat default installation options.copyright 2000 2003 The Apache Software Foundation ( http://www.apache.org). All rights reserved. 5. Specifying the installation directory. When prompted to select an installation directory (Fig.29.5), click Install to use the default directory ( C:\Program Files\Apache Group\Tomcat 4.1). Tomcat default installation directory Figure 29.5 Choosing the default Tomcat installation directory. Copyright 2000 2003 The Apache Software Foundation ( http://www.apache.org). All rights reserved.
Tutorial 29 Bookstore Web Application 847 (cont.) 6. Monitoring the installation process. The installer program will begin copying files to your computer (Fig.29.6). Figure 29.6 Tomcat installation progress dialog. Copyright 2000-2003 The Apache Software Foundation ( http://www.apache.org). All rights reserved. 7. Selecting an administrator password. Tomcat has a password-protected administration program built in. When prompted, type admin into the Password field for the User Name admin (Fig. 29.7). [Note: You can actually choose any password you like. Be sure to keep track of the password you use.] For security reasons, it is a good idea to choose your own password. This user name and password is used only when you try to access Tomcat s administration tool. You will not use the administration tool in this book. Click the Next button to continue. Figure 29.7 Selecting a Tomcat administrator password. Copyright 2000 2003 The Apache Software Foundation (http://www.apache.org). All rights reserved. 8. Completing the Tomcat installation. Once the Tomcat installation completes,click Close to finish the installation (Fig.29.8). 9. Copying the Bookstore Web application to the Tomcat webapps directory. To install the completed Bookstore Web application, copy the C:\Examples\Tutorial29\CompletedApplication\bookstore directory to Tomcat s webapps directory. The default location of the webapps directory is C:\Program Files\Apache Group\Tomcat 4.1\webapps (Fig.29.9). [ Note 1: If you chose adifferent directory in Step 6, then copy the bookstore folder to the webapps subdirectory of your Tomcat installation.] [ Note 2 :Since the completed Bookstore Webapplication is expecting to find the database information specifically in the C:\Examples\Tutorial29\ Databases directory, verify that you have copied the Tutorial29 directory on the CD to the C:\Examples directory.] [ Note 3 :At our Web site, we also provide a version for running this Webapplication on Linux.]
848 Introducing Web Applications and the Apache Tomcat Web Server Tutorial 29 (cont.) Figure 29.8 Completing the Tomcat installation. Copyright 2000 2003 The Apache Software Foundation ( http://www.apache.org). All rights reserved. Figure 29.9 Copying the bookstore folder to webapps. 10. Copying the database JAR files to the Bookstore Web application.the information tier for the Bookstore Web application uses the Cloudscape database. You need to copy the db2j.jar and license.jar files to the C:\Program Files\Apache Group\Tomcat 4.1\webapps\bookstore\WE B-INF\lib directory.the db2j.jar and license.jar files are located in the C:\Cloudscape_5.1\lib directory (Fig.29.10). In Tutorial 26, if you installed Cloudscape in a directory other than C:\Cloudscape_5.1, replace C:\Cloudscape_5.1 with your Cloudscape installation. Copying the database JAR files to the Bookstore Web appli- Figure 29.10 cation.
Tutorial 29 Bookstore Web Application 849 SELF-REVIEW 1. You must have installed before you install Tomcat. a) the Cloudscape database b) the Java 2 Software Development Kit (J2SDK) v1.4 c) aweb server d) None of the above. 2. To install the Bookstore Webapplication, you must copy it to the Tomcat directory. a) server b) work c) webapps d) None of the above. Answers: 1) b. 2) c. 29.4 Test-Driving the Bookstore Web Application In the next three tutorials, you will build aweb application that displays book information to a user upon request. Your Bookstore Webapplication must meet the following requirements: 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 Web application that allows users to view online information 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 Web 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 for you. You begin by test-driving the completed Web application. You will test the Bookstore Web application on your local computer.most computers specify a special host name localhost (which normally corresponds to the IP address 127.0.0.1) for testing Web-based applications (and other networking applications) on the local computer.as you will see in the test-drive, the URLs you will use to access the Bookstore Webapplication will contain localhost as the host name.in most cases, you can also specify your computer s name instead of localhost as the host name. [Note: If you are running Microsoft Windows on your computer, your computer s name can be determined by selecting Start > Settings > Control Panel and double-clicking System from the list to display the System Properties dialog. In Windows 2000, click the Network Identification tab. On this tab, the Full computer name: field displays your computer s name.inwindows XP, select the Computer Name tab.on this tab, the Full computer name: field displays the computer name.for other platforms, see your instructor for details on determining your computer s name.]
850 Introducing Web Applications and the Apache Tomcat Web Server Tutorial 29 Test-Driving the Web- Based Bookstore Application 1. Starting Tomcat. Tomcat must be running to respond to client requests.to start Tomcat, select Start > Programs > Apache Tomcat 4.1 >Start Tomcat.A window similar to the one shown in Fig. 29.11 will appear. Figure 29.11 Tomcat server output window. 2. Running the application. Open your Web browser and enter the URL http://localhost:8080/bookstore/books.jsp. This will request the Tomcat Web server the page, books.jsp,of the Bookstore Webapplication. The books.jsp page displays a list of the available books (Fig.29.12). Although this list GUI component looks similar to the JComboBox component you have used in desktop applications, the list is actually an HTML menu control, which is defined by the HTML select element. You will learn how to use the HTML menu control in Tutorial 30. Programmers customize Web pages by adding various HTML elements. As you will learn, some HTML elements look similar to common Java GUI components.the callouts in Fig. 29.12 identify various HTML elements that will be explained throughout this case study (Tutorial 30 Tutorial 32). 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 Figure 29.12 HTML page that display,aform with alist and abutton. The book titles displayed in the menu control are retrieved from a database. The database is the information tier of this three-tier application. Although only the book titles are displayed on this page, the database includes other information, such as the authors, cover images, prices, ISBN numbers,edition numbers,copyright years and descriptions of the books.in Tutorial 31, you will examine the application s information tier and learn how to connect to the database to access the data.
Tutorial 29 Bookstore Web Application 851 (cont.) 3. Selecting abook. Select C++ How To Program: Fourth Edition from the book list, then click the View Information button. The bookinformation.jsp page appears (Fig.29.13). This page displays the title, author and an image of the book cover of the book you selected. This page also displays the book s price, ISBN number, edition number and copyright year, as well as a description of the book. Address of bookinformation.jsp page When clicked, this link returns the user to books.jsp Figure 29.13 Page that displays the selected book s information. 4. Returning to books.jsp. After viewing abook s information, users can decide whether they wish to view information about other books.the bottom of this page contains a Book List link that, when clicked, redirects the browser back to the books.jsp page to redisplay the form that contains a list of book titles. 5. Closing the browser. Close the browser window by clicking its close button. 6. Removing the completed application from Tomcat s webapps directory. You cannot have two applications with the same name in the webapps directory.therefore, you must delete the completed application before you begin developing your Bookstore Web application over the next three tutorials. Stop Tomcat by clicking Start > Programs > Apache Tomcat 4.1 >Stop Tomcat. Then, open Windows Explorer (by double clicking My Computer on your desktop), navigate totomcat s webapps folder and delete the bookstore folder from the webapps folder (Fig.29.14) by right-clicking the bookstore folder and selecting Delete from the shortcut menu.
852 Introducing Web Applications and the Apache Tomcat Web Server Tutorial 29 (cont.) Right click bookstore Select Delete Figure 29.14 directory. Deleting the bookstore directory from Tomcat s webapps Notice that this example uses all three tiers of a three-tier application. To review: the information tier contains the database from which the Webapplication retrieves information; the client tier is represented by the Web pages in which the user views and selects books; and the middle tier is the code that controls what occurs when users interact with the Web pages requesting information from the database. SELF-REVIEW 1. Abutton in an HTML document is represented by. a) an HTML input element b) an HTML button element c) an HTML select element d) None of the above. 2. Alist of items can be displayed in aweb page with. a) an HTML input element b) an HTML button element c) an HTML select element d) None of the above. Answers: 1) a. 2) c. 29.5 Wrap-Up In this tutorial, you learned about the components of a three-tier,web-based application. You were introduced to the information tier (also called the bottom tier), which maintains the data for the application, typically as a database. You then learned about the client tier (also called the top tier), which displays the application s user interface, and the business-logic tier (also called the middle tier), which coordinates between the information and client tiers. Next, you were introduced to the Web servers. Then, you installed the Apache Tomcat Web server, which serves Web content, such as JavaServer Pages. You then test-drove the three-tier Bookstore Webapplication, learning how to start and stop Tomcat and how to run JavaServer-Pages-based applications.you also learned that HTML elements are used to create Webpages. In Tutorial 30, Bookstore WebApplication: Client Tier, you will create the user interface for this application. You will design the Web pages that display the list of books and the detailed book information. You will then proceed to Tutorial 31, Bookstore WebApplication: Information Tier, where you will learn about the data-
Tutorial 29 Bookstore Web Application 853 base used in the application and how the application connects to that database.you will complete the Bookstore Web application in Tutorial 32, Bookstore Web Application: Business Logic Tier.In that tutorial, you will write the functionality for the entire Bookstore Webapplication. SKILLS SUMMARY KEY TERMS Installing Tomcat Locate jakarta-tomcat-4.1.24-le-jdk14.exe on the CD and double click it to run the installer program. Follow the prompted instructions to complete the installation. Starting Tomcat Select Start > Programs > Apache Tomcat 4.1 >Start Tomcat. Stopping Tomcat Select Start > Programs > Apache Tomcat 4.1 > Stop Tomcat. Setting up a Web Application on Your Computer Place the Web application s folder in your Tomcat webapps directory (if you installed Tomcat in the default directory, this directory is C:\Program Files\Apache Group\ Tomcat 4.1\webapps). Testing the Web Application Using a Web Browser Open aweb browser. Type the URL http://localhost:8080/nameofapplication/ nameoffirstpage, where nameofapplication is the name of the Webapplication s directory and nameoffirstpage is the name of the first Webpage (such as a JSP page) that loads when the application is run. Press Enter to run the application. Apache Tomcat A Web server from the Apache Group that is free and available for many platforms. bottom tier The tier (also known as the information tier, or the data tier) containing the application data of amulti-tier application typically implemented as a database. client tier The user interface of amulti-tier application (also called the top tier). data tier The tier (also known as the information tier, or the bottom tier) containing the application data of amulti-tier application typically implemented as a database. DNS lookup The process that translates fully qualified domain names into IP addresses. domain Represents a group of hosts on the Internet. domain name Also known as a Web address, which uniquely identifies the location of a business or organization on the Internet. Domain Name System (DNS) server A computer that maintains a database of host names and their corresponding IP addresses. fully qualified domain name (FQDN) A host name combined with a domain and top-level domain that provides a user-friendly way to identify a site on the Internet. host A computer that stores and maintains resources, such as Web pages, databases and multimedia files. HTML element A part of the HTML language, such as h1, select or input, that determines the format of aweb page and the GUI components that appear on aweb page. HyperText Markup Language (HTML) A language, understood by virtually all Web browsers, used to publish online documents with forms and images. information tier The tier containing the application data of a multi-tier application typically implemented as a database (also called the bottom tier or database tier). IP (Internet Protocol) address A unique address used to locate a computer on the Internet. JavaServer Pages A technology to develop dynamic Web pages through the use of Java and HTML. localhost The host name that identifies the computer you are using.
854 Introducing Web Applications and the Apache Tomcat Web Server Tutorial 29 middle tier The tier that controls interaction between the client and information tiers of a multi-tier application. This is sometimes known as the business logic tier. multi-tier application Application (sometimes referred to as an n -tier application) whose functionality is divided into separate tiers, which can be on the same machine or can be distributed to separate machines across anetwork. One popular form of multi-tier application has three tiers the client tier, which contains the application s user interface, the information tier, which maintains the data for the application and the business logic tier, which controls interactions between application clients (such as Web browsers) and application data in the information tier. Sometimes referred to as n-tier application. tier Logical groupings of functionality. top-level domain (TLD) The portion of a Web address that usually describes the type of organization that owns the domain name. For example, the com TLD usually refers to a commercial business, the org TLD usually refers to a nonprofit organization and the edu TLD usually refers to an educational institution. top tier The tier containing the application s user interface in a multi-tier application typically implemented as a GUI. URL (Uniform Resource Locator) An address that can be used to direct a browser to a resource on the Web. Web address Also known as a domain name, which uniquely identifies the location of a business or organization on the Internet. Web application Also known as Web-based application, can use JavaServer Pages (JSP) technology to create Web content. Web content Data that can be viewed in a Web browser, such as Internet Explorer or Netscape. Web server Specialized software that responds to Web client requests by sending Web pages and other resources back to the client. MULTIPLE-CHOICE QUESTIONS 29.1 JavaServer pages have the extension. a).html b).jsp c).javasp d) None of the above. 29.2 applications divide functionality into separate tiers. a) n -tier b) Multi-tier c) Both aand b. d) None of the above. 29.3 All tiers of amulti-tier application. a) must be located on the same computer b) must be located on different computers c) can be located on the same computer or on different computers d) must be arranged so that the client and middle tier are on the same computer and the information tier is on adifferent computer 29.4 The client tier interacts with the tier to access information from the tier. a) middle, information b) information, middle c) information, bottom d) bottom, information 29.5 A is specialized software that responds to client requests from Webbrowsers by providing resources. a) host b) host name c) DNS server d) Web server 29.6 A(n) can be thought of as an address used to direct a browser to a resource on the Web. a) middle tier b) ASPX page c) URL d) query string
Tutorial 29 Bookstore Web Application 855 29.7 A represents a group of on the Internet. a) domain, hosts b) host, domain names c) host name,hosts d) None of the above. 29.8 is a Web server. a) Apache Tomcat b) localhost c) Java d) None of the above. 29.9 A is a special host name that identifies the local computer. a) localhost b) local Web server c) remote Web server d) None of the above. 29.10 The tier is the application s user interface. a) middle b) client c) bottom d) information EXERCISES 29.11 ( Phone Book Web Application) Over the next three tutorials, you will create a Phone Book Webapplication. This phone book should be aweb-based version of the Phone Book application created in Tutorial 28. [ Note: This Web application will not use the Java Speech API as in Tutorial 28.] The Phone Book Webapplication should consist of two JSP pages, which will be named phonebook and phonenumber.the phonebook page displays alist containing the names of several people.the names are retrieved from the phonebook database.when aname is selected and the Get Number button is clicked, the client browser is redirected to the phonenumber JSP page.the telephone number of the selected name should be retrieved from adatabase and displayed in the phonenumber JSP page.for this exercise, you need only organize the components ( phonebook and phonenumber JSP pages, phonebook database and the code that performs the specified functionality) of this Webapplication into separate tiers. Decide which component belongs in which tier.you will begin building the application in the next tutorial. 29.12 ( US State Facts WebApplication) Over the next three tutorials, you will create a US State Facts Web application. This application is designed to allow users to review their knowledge about various U.S. states.this application should consist of two JSP pages.the first page (named states) should display a list containing 10 different state names. These state names are stored in the StateFacts database.the user should be allowed to select a state name from the list and click a button to retrieve information about the selected state from the database. The information should be displayed on a different JSP page (named statefacts). The statefacts page should display an image of the state flag and list the state capital, state flower, state tree and state bird (retrieved from the database). You will be provided with images of the state flags. For this exercise, you need only organize the components ( states and statefacts JSP pages, StateFacts database and the code that performs the specified functionality) of this Webapplication into separate tiers.decide which component belongs in which tier.you will begin building the application in the next tutorial. 29.13 ( Road Sign Review Web Application) Over the next three tutorials, you will create a Road Sign Review Web application. The Road Sign Review Web application should consist of two JSP pages.this application displays road signs for the user to review and allows the user to schedule adriving test. Thefirst page (named roadsigns) should display 15 road sign images that will be provided for you. The page should display the images by retrieving their information from the RoadSigns database.this page also will contain two input fields (which look like JTextFields) and abutton that allow the user to enter information to register for a driving test. When the user clicks the Register button, the second page (roadtestregistered)displays information confirming that the user has registered for adriving test. For this exercise, you need only organize the components (roadsigns and roadtestregistered JSP pages, RoadSigns database and the code that performs the specified functionality) of this Webapplication into separate tiers.decide which component belongs in which tier.you will begin building the application in the next tutorial.