3. 1. Introduction
The World Wide Web, or WWW in short, is a system of documents accessed via the internet
using standard protocols. The web should not be confused with the internet. The web is
described in the terms of protocols and document specifications maintained by the World
2
Wide Web consortium, or W3C in short. Those protocols and documents are clouded on the
internet. In other words, the web is a part of the internet.
2. HTTP
Hypertext Transfer Protocol, or HTTP in short, is an application level protocol for distributed
hypermedia (text, image, video, etc) information systems, developed by the W3C. The main
purpose of HTTP is to retrieve inter-linked hypertext documents from the internet. A common
example is every day passing time on facebook. You do retrieve different types of media from
the facebook website using the HTTP protocol that's familiar to both, the web server hosting
the facebook website, and the web browser you use to access facebook website.
Some facts about HTTP:
• HTTP works in client/server architecture.
• The client is the web browser.
• The server is the web server.
• The client is referred to as the user agent.
• The server is referred to the origin server.
• HTTP is request/response protocol, i.e. user agent requests, origin server responses,
connection is closed.
• One consequence of the previous fact is that HTTP is a stateless protocol, i.e. no state
is shared between different requests.
2. W3C, founded and headed by Sir Tim Berners-Lee, credited the father of the web. See
http://www.w3c.org/.
3
4. 2.1. HTTP Request
An HTTP request is sent by the user agent to a web origin after establishing a connection with
it. The purpose of an HTTP request is to retrieve some resource. The request consists of:
Request Line: the method of retrieving the resource in addition to the path to this
resource. Popular methods are GET and POST.
GET Method: parameters can be passed to resources in the URL.
POST Method: parameters can be passed to resources also, but the in the
body of the request.
Request Headers: a set of key-value attributes giving some metadata about the
request.
2.2. HTTP Response
An HTTP response is sent by the web origin to the user agent before closing the connection
with it. The purpose of HTTP response is to reply to the user request with either the resource
or some other replies with failure or security insufficiencies. The response consists of:
Response Line: Status code (informing reply message) in addition to a textual
message.
Response Headers: a set of key-value attributes giving some metadata about the
response.
Resource content: the content of the requested resource.
2.3. HTTP Session
Because HTTP is a stateless protocols, stateful applications of user logins and online shop-
cards cannot be directly implemented using HTTP. That's because those type of applications
needs to remember state among a sequence of requests. To meet this requirement, the
concept of HTTP session was introduced.
An HTTP session is a set of HTTP requests. The main purpose of a session is to remember
state about the client among those requests. This supports all types of applications that
needs to make a conversation with the client. An HTTP session is supported by browser-
cookies. A browser-cookie is some state that can be stored by the origin server on the
user agent and retrieved on later requests. It lets the server remembers some state about
a sequence of requests for a specific client. In other words, browser-cookies are variables
inside the browser accessed by some origin server. Browser-cookies have expiration-dates
that determines the timeout of the HTTP session.
4
5. 3. HTML
Hypertext Markup Language, or HTML in short, is a standard language for representing
structural documents of different types of media (text, image, video, etc), developed by the
W3C. The main purpose of HTML is to describe the hierarchical structure of a hypermedia
page that needs to be rendered using some type of applications called web browsers.
Some facts about HTML:
• HTML is a representational language, not a programming language.
• HTML is rendered using a web browser.
• HTML does not do actions. However, scripts of actions can be embedded in some
client-side scripting language such as javascript.
4. Web Server
A web server is an application that supports hypermedia distribution over the internet. It
implements the HTTP protocol and manages different media resources to provide it to users
on request. The most popular web server is Apache Web Server. It's open source and can be
downloaded from (http://www.apache.org).
5. Web Browser
A web browser is an application that used to access and view hypermedia resources
managed by some web server using HTTP protocol. It requests resource documents from
a web server and render those documents to the viewer. Most popular web browsers are
Microsoft Internet Explorer and Mozilla Firefox.
6. The Dark Age
Not too long ago, websites was just static HTML pages linked together with no activity with
the user. The user is allowed only to view static resources, lazily manually updated by the
website administrator. The web was no more just static resources. This feature changed a lot
as today websites gradually tended to be web applications.
7. The Dynamic Age
Today, most websites are interactive. Users can interact with websites in forms of
comments, edits, shares, uploads, etc. For example, the content of the facebook homepage
is dynamically changeed every time you visit it as it fetches latest posts by all of your friends.
Those types of resources cannot be built in static HTML pages and needs server-side scripting
technologies like PHP, ASP, or Servlets and JSP as we will be involved in Java EE.
5
6. 8. Examples
8.1. HTML Skeleton
file: skeleton.html
<html>
<!-- This is the header section, not displayed on screen -->
<head>
<title>Page Title Here</title>
</head>
<!-- This is the body section, displayed on screen -->
<body>
<h1>Topic</h1>
Content
</body>
</html>
8.2. HTML Registration Form
file: registration.html
<html>
<head>
<title>HiQ Training</title>
</head>
<body>
<h1>Student Registration Form</h1>
<!-- This is the form section -->
<form action="process.jsp" method="POST">
Student Name:<input type="textfield" name="student_name"/>
Training Course:<input type="textfield"
name="training_course"/>
<input type="submit" value="Register"/>
</form>
</body>
6
7. </html>
8.3. HTTP Request
Internet Explorer <request: http://www.yahoo.com/abc/foo.html>
GET /abc/foo.html HTTP/1.1
Host: www.example.com
User-Agent: MSIE 6.0
8.4. HTTP Response
Web Server <response>
HTTP/1.1 200 OK
Server: Apache
Content-Type: text/html
Content-Length: 31837
<html>
<!-- Page content goes here -->
</html>
8.5. Dynamic Page (JSP)
8.5.1. JSP Page
file: foo.jsp
<html>
<head>
<title>First JSP Page</title>
</head>
<body>
<h1>
<%
int x = 5 ;
int y = 7 ;
int z = x + y ;
out.print(z) ;
%>
</h1>
</body>
</html>
7