Java Reference
In-Depth Information
Chapter 14
A Java web server
14.1 Introduction
Aweb server program runs continuously while waiting for and answering requests
it receives over the Internet from browsers. Typically the requestor asks for the
transmission of a web page in HTML (Hypertext Markup Language) format or
asks for some other HTTP (Hypertext Transmission Protocol) service such as the
running of a CGI (Common Gateway Interface) program.
Developing web servers and server applications such as online stores became
the first big money-making business area that used Java extensively. Sun offers
additional packages with the Java 2 Platform Enterprise Edition (J2EE) to sup-
port server development for applications such as database access, shopping cart
systems for web stores, and other elaborate middleware services that can scale
to large numbers of client users. Companies like IBM and BEA have been quite
successful in selling their own middleware Java software.
In this chapter and the next we look at a simple socket-based approach to
building web servers for specialized applications [1-4]. This can be done with
the classes available in J2SE. In Chapters 16-20 we focus on RMI (Remote
Method Invocation) clients and servers and other distributed computing tech-
niques. In Chapter 21 we return to web-based networking with a discussion of web
services.
We show here how to create a simple web server that could run on any plat-
form that implements a JVM with the java.net and java.io packages. Such
a micro-server could, for example, run on remote devices in a scientific exper-
iment and provide data and status information to client programs. It could also
accept instructions for operating the devices, installing calibration data, and so
forth.
These devices are not theoretical. In Chapter 24 we discuss commercially
available processor cards that provide both network access and a JVM (or a
hardware implementation) with which to run such a server program. The cards are
intended for embedded applications such as monitoring and controlling sensors
431
Search WWH ::




Custom Search