A Debugging Web Server in Java
Description
EchoServer is a free HTTP server that generates an HTML
document showing the HTTP request and headers sent to it.
I use it widely for debugging FORM submissions and for checking
what kind of HTTP headers are sent by various browsers in various
circumstances, or if an applet or custom client is sending the proper
HTTP headers.
It handles either GET or POST requests,
and comes in single-threaded or multi-threaded versions. It runs
in either Java 1.02 or 1.1. If compiling in 1.1, you can ignore the
small number of "deprecation" warnings when compiling.
Source Code
-
ThreadedEchoServer. The multi-threaded server version; allows
multiple simultaneous HTTP connections. Requires all of the
classes below.
-
EchoServer. The basic debugging Web server on which the
threaded version is built. Requires the NetworkServer and
SocketUtil classes.
-
NetworkServer. A basic template for socket-based servers in
Java, on which several programs (including the EchoServer) are
built. Requires the SocketUtil class.
-
SocketUtil.
A utility class that simplifies the creation of buffered and
unbuffered I/O streams associated with sockets.
Core Web Programming
This code is extracted from Chapter 15 of
Core Web Programming.
For more info, see
the reader reviews,
the on-line ordering page,
the table of contents,
the source code archive (250+ Java classes,
200+ HTML/JavaScript docs presented in the book), and
a sample chapter in HTML ("Graphical User
Interface Controls" from the Java section).