Serfler
Prepared by Douglas Harris
doug@mscs.mu.edu
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.
-
It supports property settings for the server both from properties files,
and from the startup command line.
-
It supports loading of servlets both from properties files, and dynamically
from a browser (soon only for those with proper authorization!).
-
It provides full support for forms, and cookies.
-
It provides customizable icons for directory listings, and will soon allow
the type of listing to be customizable via a cookie for each browser.
-
There is a simple facility for dynamically producing HTML
pages as output.
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
-