Java: A platform for platforms
Sun's reorg may seem promising to shareholders but it's also a scramble for position. The question now is whether Sun can, or wants to, maintain its hold on Java technology. Especially with enterprise leaders like SpringSource and RedHat investing heavily in Java's future as a platform for platforms

Also see:

Discuss: Java: A platform for platforms?

Featured Whitepapers
Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Are you Being Served?

SunSoft's implementation of the Java Server API outperforms Perl and CGI. Here's the how and why -- plus an example servlet

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
If you have spent any time in England or any of the Commonwealth countries or watch much PBS, you probably have seen the long-running TV situation comedy "Are You Being Served?" about a bunch of wacky department store clerks who get into the most ridiculous jams while trying to service their customers.

Service industry hi-jinx aside, fulfilling orders and requests is, for the most part, a methodical process involving predictable parameters for input and output -- a task that's better suited to computers than human clerks. Once you've committed to going hi-tech, the question turns to software. Now, thanks to Jeeves, Java is one of your options.

In this column in our series on the Java API family, we introduce the Java Server API, also called, in somewhat quaintly British fashion, Jeeves. This API allows programmers to rapidly create connection-oriented server applications using a pre-defined architecture and providing the supporting object classes necessary.

Support service

The Server API is very much designed for the Web, although technically it can be used for any generic TCP/IP services. Jeeves itself is an HTTP or Web server that can be extended to include other protocols and applications. Each Web connection is processed by a servlet. This is similar in concept to a server application, but with minimal overhead and handling only the portions of the service workflow for which it is designed. Programmatically, the servlet is similar to an applet with the exception that there is no need for a graphical interface to the program. It is a piece of Java bytecode that can be downloaded from the network if necessary.

The Jeeves framework provides all the needs for handling multiple connections, managing a pool of servlets, keeping track of backlog, and dispatching service requests using a given set of classes.

Basically, it begins with the main server loading up, binding to a TCP/IP port, and starting a pool of servlets. The server resides on this port and accepts incoming connections, which are placed in a queue for processing by the servlets. Before passing this connection to an awaiting servlet, the server checks the servlet pool to see that enough servlets are available for future requests. The server can maintain a fixed pool of servlets or it can dynamically add and remove servlets from the pool to satisfy the requirements of the application.

The server will pass a request only to a servlet of the appropriate type for handling the request. There can be several pools of servlets, each a different type of request handler. For example, one servlet can handle HTML file requests, another can serve CGI requests, and still others can handle application-specific requests. Each servlet is designed to handle only its own area of service and thus does not need the huge overhead of traditional Web servers, where each server process needs to know how to handle everything. This makes for compact programs that can execute in a fast and efficient manner, supported by other programs that can handle other tasks more suited to them.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources