Java Reference
In-Depth Information
Java plays a key role in this new paradigm. Java running on the server provides
a robust and high-performance environment for developing and running applica-
tions. Although servlets and Java Server Pages (JSPs) can be used for both presen-
tation and business logic, good design principles usually require a separation of the
two. Servlets and JSPs in most designs are used for presentation logic. Business logic
in the full-blown Java Enterprise Edition (JEE) environment is usually handled by
Enterprise JavaBeans, the subject of the next chapter.
B ROWSERS AND W EB S ERVERS
To do Web development, you need to understand how Web servers work and how
they interact with their clients, the browsers. Once this understanding is in place,
you will readily see how servlets and JSPs fit into the picture.
The simplest requirement of a Web server is to serve static HTML pages and im-
ages. In doing this activity, Web servers are really file servers. The files they serve are
text files containing HTML and their associated images and resources. The clients
they serve are usually browsers. The protocol for the communication is Hypertext
Transfer Protocol (HTTP). Modern Web servers, of course, can do much more than
simply serve files, but let's stay with the simplest communication for the moment.
The client, usually a browser, opens a connection to the server. After it gets a
connection, it sends a request that is formatted correctly for HTTP. The server re-
sponds according to what was requested, in a form that is formatted correctly for
the protocol. The connection is closed.
Each request from the client and response by the server is an autonomous com-
munication. Each runs independently from all that went before it and from all that
came after it. The transaction is stateless. No persistent connection exists between
the client and the Web server. No “memory” of other transactions is built into the
protocol. The protocol was designed this way for speed.
Now you'll dissect a simple transaction to a deeper level. Let's pretend you
have installed a Web server on your machine and have placed a simple HTML doc-
ument called resume.html in the root directory that the Web server uses to serve
files. This directory is configurable for each Web server. The machine is running at
IP address 90.121.111.5.
Search WWH ::




Custom Search