Serfler


   Prepared by Douglas Harris    doug@mscs.mu.edu
serfler logo

Serfler is a simple but powerful HTTP server, written entirely in Java, whose operation is based almost entirely upon servlets.

Currently it implements the HTTP 1.0 protocol, and portions of the HTTP 1.1 protocol, and it is intended to be fully HTTP/1.1 compliant very soon.

It was written initially as a demonstration of client/server programming for HTTP, and has turned out to be very useful in real life.

Currently Serfler is distributed under the terms of the Gnu Public License. The intent is that anyone who finds it useful at this point may use it. The author would like to be credited for his ideas (good or bad), would like feedback from anyone who uses or abuses it, and can make no guarantees regarding reliability, performance, or anything else.

To download the source code:
Serfler.zip.


Description

Serfler is an HTTP server which is based entirely on servlets. Every function beyond basic parsing of the incoming HTTP is done with a servlet.

The Servlets

There are 5 basic servlets, which are in their own package Serflet.Servlet separate from ordinary servlets, loaded and administered separately.
FileServlet
LoadServlet
DefaultServlet
UnknownServlet
ErrorServlet
It is also possible to dynamically load servlets, by placing them in the directory

/javadev/servletCode
and telling the server about them with the syntax

http://server:port/servlet/name=byteCodeFileName?init1=val1&init2=val2
where the QueryString specifies initialization parameters.

The Server

The main program to start Serfler is SerflerServer. It creates a queue of SerflerHandlers, and listens for a connect. It is holding a handler off the queue, and when an accept returns it starts the handler running. The handler reads the incoming HTTP, and decides which servlet.service() should handle the query and provide the reply.
SerflerServer
SerflerHandler
SerflerContext
Keeps track of the servlets, and does the loading and initialization.
SerflerConfig
Knows how to handle parameters for the Servlets.
SerflerInputStream
SerflerOutputStream
SerflerSession