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
-
servlets
-
-
Serve()
- Constructor, default port and log stream.
-
Serve(int)
- Constructor, default log stream.
-
Serve(int, PrintStream)
- Constructor.
-
addDefaultServlets()
- Register a standard set of Servlets.
-
addServlet(String, String)
- Register a Servlet.
-
getInitParameter(String)
- Gets an initialization parameter of the servlet.
-
getServerInfo()
- Returns the name and version of the web server under which the servlet
is running.
-
getServlet(String)
- Gets a servlet by name.
-
getServletContext()
- Returns the context for the servlet.
-
getServlets()
- Enumerates the servlets in this context (server).
-
log(Servlet, String)
- Write information to the servlet log.
-
log(String)
- Write information to the servlet log.
-
serve()
- Run the server.
servlets
protected Hashtable servlets
Serve
public Serve(int port,
PrintStream logStream)
- Constructor.
Serve
public Serve(int port)
- Constructor, default log stream.
Serve
public Serve()
- Constructor, default port and log stream.
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.
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.
serve
public void serve()
- Run the server. Returns only on errors.
getServletContext
public ServletContext getServletContext()
- Returns the context for the servlet.
getInitParameter
public String getInitParameter(String name)
- Gets an initialization parameter of the servlet.
getServlet
public Servlet getServlet(String name)
- Gets a servlet by name.
- Parameters:
- name - the servlet name
- Returns:
- null if the servlet does not exist
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.
log
public void log(String message)
- Write information to the servlet log.
- Parameters:
- message - the message to log
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
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>