Class Acme.Serve.Serve
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Acme.Serve.Serve

java.lang.Object
   |
   +----Acme.Serve.Serve

public class Serve
extends Object
implements ServletStub, ServletContext
Minimal Java HTTP server class.

This class implements a very small embeddable HTTP server. It runs Servlets compatible with the API used by JavaSoft's Jeeves server. It comes with a default Servlet which provide the usual httpd services, returning files and directory listings.

This is not in any sense a competitor for Jeeves. Jeeves is a full-fledged HTTP server. Acme.Serve is tiny, about 900 lines, and provides only the functionality necessary to deliver an Applet's .class files and then start up a Servlet talking to the Applet. They are both written in Java, they are both web servers, and they both implement the Servlet API; other than that they couldn't be more different.

This is actually the second HTTP server I've written. The other one is called thttpd, it's written in C, and is also pretty small although much more featureful than this.

Other Java HTTP servers:

Fetch the software.
Fetch the entire Acme package.

See Also:
Servlet, DefaultServlet, SampleServe

Variable Index

 o servlets

Constructor Index

 o Serve()
Constructor, default port and log stream.
 o Serve(int)
Constructor, default log stream.
 o Serve(int, PrintStream)
Constructor.

Method Index

 o addDefaultServlets()
Register a standard set of Servlets.
 o addServlet(String, String)
Register a Servlet.
 o getInitParameter(String)
Gets an initialization parameter of the servlet.
 o getServerInfo()
Returns the name and version of the web server under which the servlet is running.
 o getServlet(String)
Gets a servlet by name.
 o getServletContext()
Returns the context for the servlet.
 o getServlets()
Enumerates the servlets in this context (server).
 o log(Servlet, String)
Write information to the servlet log.
 o log(String)
Write information to the servlet log.
 o serve()
Run the server.

Variables

 o servlets
  protected Hashtable servlets

Constructors

 o Serve
  public Serve(int port,
               PrintStream logStream)
Constructor.
 o Serve
  public Serve(int port)
Constructor, default log stream.
 o Serve
  public Serve()
Constructor, default port and log stream.

Methods

 o addServlet
  public void addServlet(String urlPat,
                         String className)
Register a Servlet. Registration consists of a URL pattern, which can contain wildcards, and the class name of the Servlet to launch when a matching URL comes in. Patterns are checked for matches in the order they were added, and only the first match is run.
 o addDefaultServlets
  public void addDefaultServlets()
Register a standard set of Servlets. These will return files or directory listings much like a standard HTTP server. Because of the pattern checking order, this should be called after you've added any custom Servlets.
 o serve
  public void serve()
Run the server. Returns only on errors.
 o getServletContext
  public ServletContext getServletContext()
Returns the context for the servlet.
 o getInitParameter
  public String getInitParameter(String name)
Gets an initialization parameter of the servlet.
 o getServlet
  public Servlet getServlet(String name)
Gets a servlet by name.
Parameters:
name - the servlet name
Returns:
null if the servlet does not exist
 o getServlets
  public Enumeration getServlets()
Enumerates the servlets in this context (server). Only servlets that are accesible will be returned. This enumeration always includes the servlet itself.
 o log
  public void log(String message)
Write information to the servlet log.
Parameters:
message - the message to log
 o log
  public void log(Servlet servlet,
                  String message)
Write information to the servlet log.
Parameters:
servlet - the servlet to log information about
message - the message to log
 o getServerInfo
  public String getServerInfo()
Returns the name and version of the web server under which the servlet is running. Same as the CGI variable SERVER_SOFTWARE.

All Packages  Class Hierarchy  This Package  Previous  Next  Index

ACME Java  ACME Labs

Jef Poskanzer <jef@acme.com>