2. JSP and Servlets / Session 1 / 2 of 15
Objectives
Describe a multi-level architectural view of a
Web application.
Review HTTP protocol
Describe the anatomy of a typical Web
Application.
Describe the Web development process
Setup Tomcat environment in Java Studio
Enterprise 8.
3. JSP and Servlets / Session 1 / 3 of 15
Desktop Applications 2-1
User Windows Media Player
User selects an mp3 file
Media Player playing the mp3 file
4. JSP and Servlets / Session 1 / 4 of 15
Desktop Applications 2-2
User Windows Media Player
Request = Select a file to play
User sends a request
Player sends a response
Response = Media Player plays the selected file
Media Player is an example of desktop application
5. JSP and Servlets / Session 1 / 5 of 15
Web Applications 2-1
Web Site hosted on a
Web Server
www.mp3.com
6. JSP and Servlets / Session 1 / 6 of 15
Web Applications 2-2
www.mp3.com Web Application
Web Application running on a Web Server
User requests a song
Song is played in response
Advantages of Web Applications:
•Accessing Web Applications is easier
•Maintenance and deployment costs are low
7. JSP and Servlets / Session 1 / 7 of 15
HTTP Protocol 3-1
Get File HTTP
GET
image/bar01.jpg
HTTP/1.1
HTTP/1.1 200 OKFile Received
HyperText Transfer Protocol
Stateless protocol
Used to send request and response messages over the
Internet.
Uses port 80 to send and receive messages
8. JSP and Servlets / Session 1 / 8 of 15
HTTP messages consist of:
Request
Response
Headers
HTTP Protocol 3-2
Request Message
Request Line
Header Information
Method Resource Name Version
GET/POST bar01.jpg HTTP/1.1
Browser Type Content Type
User-Agent: Mozilla/4.0 (Compatible; MSIE 4.0 : Windows 95
Accept: image/gif, image/jpeg, text/*, */*
Response Message
Status Line
Header Information
Version Status Code Description
HTTP/1.1 200 OK
Server
Software
Modified
Date
Size
(bytes)
Content
Type
Server: JavaWebServer
Last modified: Tuesday, 07-Sep-04 1:14:34 GMT
Content-length: 100
Content-type: text/plain
9. JSP and Servlets / Session 1 / 9 of 15
HTTP Protocol 3-3
HTTP protocol uses the following methods to send
request messages:
GET Method
POST Method
GET Method
Used for retrieving information such as
document, charts, or database query
results.
Requested pages can be bookmarked and
emailed.
Request information is sent as query string
POST Method
Used to send sensitive information such as
credit card numbers or information to be
saved in the database.
Requested pages cannot be bookmarked
or emailed.
No size limit on information being sent
query string
(240-255 characters)
10. JSP and Servlets / Session 1 / 10 of 15
Application Architecture
Software Application Components
-Presentation Logic
-Application Logic
-Data Access Logic
Types of Architecture
-One-Tier
-Two-Tier
-Three-Tier
Data Access
Business
Presentation
Data Access
Business
Presentation
11. JSP and Servlets / Session 1 / 11 of 15
Web Application Architecture
Web Applications use Three-tier architecture
Presentation Tier
Clients
Business Tier
Web Server
Database
Data Tier
12. JSP and Servlets / Session 1 / 12 of 15
Web Application Directory Structure
Web Application
HTML files
Images
Servlets
JSP pages
JavaBeans
Jar files
Applets
Tag files
Tag Library
Descriptor files
Deployment
descriptors
.war file
Document Root
Static Files(html, images, JSP) WEB-INF
lib tags .tld, web.xmlclasses
Web Application Directory Structure
index.html, login.jsp, contactus.jsp
ViewBooks.jsp, logo.jpg
book1.jpg
AddBook.class,
DeleteBook.class
mbase.jar,
msqlserver.
jar,
msutil.jar
DisplayBook.tag web.xml, books.tld
13. JSP and Servlets / Session 1 / 13 of 15
Web Application Development Process
Design a directory structure
Write web application code
Write deployment descriptor
Compile the code
Package web application
Deploy web application
Execute web application
14. JSP and Servlets / Session 1 / 14 of 15
Tomcat Configuration
Demonstration
Steps to configure Tomcat in Java Studio
Enterprise 8
Select ToolsServer Manager
15. JSP and Servlets / Session 1 / 15 of 15
Summary
Web applications are easy to maintain, upgrade and
deploy as compared to desktop applications.
Pages requested using GET method can be bookmarked
and emailed.
POST method is used when sending sensitive
information such as credit card numbers, passwords and
so on.
In three-tier architecture, the presentation tier cannot
interact with the data tier.
JBuilder Enterprise 2005 can be configured to use
external Tomcat installation.