Learn Java for Web Development

(Tina Meador) #1

90 CHAPTER 2: Building Web Applications Using Servlets and JSP


In the MVC architecture shown in Figure 2-36, M stands for Category, V stands for home.jsp, and C
stands for BookController. The application flow comprises six steps, as discussed in the following
sections.


Step 1: Locating the Servlet from the Request

The URL (http://localhost:8080/bookWeb/books) is for the dynamic content, so the web server
forwards the request to the servlet container (Tomcat). Listing 2-27 illustrates the Deployment
Descriptor.


Listing 2-27. Deployment Descriptor of the BookstoreWeb App


1.<?xml version="1.0" encoding="UTF-8"?>
2.<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3.xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4.xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
5.id="WebApp_ID" version="3.0">
6.bookWeb
7.
8.BookServlet
9.com.apress.bookweb.controller.BookController
10.
11.base
12./bookWeb/books
13.

14.
15.imageURL
16./bookWeb/images
17.

18.1
19.

20.
21.param1
22./bookWeb/books
23.

24.
25.imageURL
26./bookWeb/images
27.

28.
29.BookServlet
30./books
31.

32.
33.index.html
34.index.htm
35.index.jsp
36.default.html

Free download pdf