Web Server Architecture
Very simple basic model:
Server listens to Client request messages on the "well known" HTTP port (80) and return results.
Interaction is governed by the Hypertext Transfer Protocol RFC 1945, 2616.
Web Server is a daemon -- handles multiple requests simultaneously for the same client or for different Clients.
HTTP
stateless
client/server: request/response for single file so that the the specific page may require many requests.
request:
server:
response:

Small efficient programs generate the requested web page -> less chance to
get outdated files -> more up-to-date information
Today: move to executable content.

CGI: Common Gateway
Interface
(originally from gopher)
Input to CGI program through environmental information:
environmental variables
Output to CGI program written to standard output, sysout is data returned to browser.
Some variables such as HTTP.USER.AGENT allow customization of web content to use specific client browser features.
CGI programs can be written in most languages. Typically: C, Perl, Schell-scripts, and Java as well. Originally: java myprog, ->
may crash, inefficient + slow, because:
new process
new JVM initialization
wasteful of machine resources (memory)
New: Servlets
Server-side Java applications that dynamically produce HTML, do database queries, and integrate the two.
Use Servlets instead of CGI Scripts!
Servlets are an effective replacement for CGI scripts. They provide a way to generate dynamic documents that is both easier to write and faster
to run. Servlets also address the problem of doing server-side programming with platform-specific APIs: they are developed with the Java Servlet API,
a standard Java extension.
Why not use RMI?
Normal Java objects have public interfaces and they are instantiated every time one is needed.
Servlets have no defined interfaces. Java web server maps a request onto a servlet and passes the entire URL call. Servlet then creates the dynamic contend.

Servlet API:
request object -> servlet -> response object -> server